4

I want to ask about connect database at website to my office database.

I have a website that hosted at a shared hosting server. I'm using PHP for the web and MySQL for database. Now, what I want is my website at the server connect to my MySQL database at my office database. Is there anyway to do that?

What I can do right now is my office app connect to database at web (remote MySQL) but what I need is the opposite, my web connect to my office database.

Sorry for my bad English.

Celia Tan
  • 165
  • 7
  • Does your computer have a publically accessible IP address? If so, then just point the configuration of the PHP site at that IP address instead of wherever it is now. (If not you'll have to get a publically accessible IP address. If you're using a PC behind a WiFi router's NAT, that will involve setting up port forwarding and preferrably a DDNS service. If your network setup is something else, It Depends. – millimoose Jan 21 '13 at 02:24
  • Yes, I have Public IP. So I just put my Public IP to my connection file at server right? I will try it now. Thanks for Your response. – Celia Tan Jan 21 '13 at 02:33
  • So I guess nobody is going to mention that opening a MySQL server on a public IP address is a really, really bad idea? – Perception Jan 21 '13 at 04:05
  • Why it's a bad idea? My boss want me to do that. Maybe I can tell her what will happened when I'm using this method. – Celia Tan Jan 21 '13 at 04:10
  • Is this database going to contain information critical to your business? A publicly accessible MySQL server will be hit by script kiddies within minutes of its being up. – Perception Jan 21 '13 at 04:16
  • well it's not, the database only contain sms data that sent from my sms gateway. – Celia Tan Jan 22 '13 at 01:34

1 Answers1

2

MySQL is network database server and you can login from anywhere...

... if there is a network connection between computers :)

  1. You just have to configure MySQL user permissions and allow login from that other machine (its IP-configurable, or you can allow any IP). By default MySQL user can login only from localhost. More information (you can use IP instead of domain)

  2. You may have to ask your home/office internet provider (or network admin) to provide/configure "public IP".

  3. You may need to set up "virtual server" on your home/office router and configure any firewalls in home/office. MySQL uses 3306 port by default.

  4. Added later: you may have to enable TCP/IP protocol in MySQL configuration. More...

One more thing - "localhost" means connecting computer to itself without network. If you are talking about 2 computers - better say "other computer" or "home computer", not "localhost".

Community
  • 1
  • 1
Kamil
  • 13,363
  • 24
  • 88
  • 183
  • Oh yes. I want to connect my website to database at my computer/server office. I will try to use Public IP. Thanks for response. – Celia Tan Jan 21 '13 at 02:34
  • You might need to open port 3306 – hd1 Jan 21 '13 at 02:50
  • Right now I have my IP Public and opening port 3306, but still it can't connect to my office database. How to change mysql user permissions at my office database? – Celia Tan Jan 21 '13 at 03:54
  • Using grant and opening port and create virtual server... Finally did it. Thank You Kamil... :D – Celia Tan Jan 22 '13 at 01:34