Connecting PHP to MYSQL Database in another machine

If you had webserver and you had another mysql that hosting your database, and it is kept in another machine and you want to connect it via your local area network, so you need to grant access for remote connection on that mysql.

Please run the following script on SQL command at that mysql database :

                ‘[user]’@'[hostname]’ identified by

Note : replace [dbname] with your database name, replace [user] with your username or you can put root as default, replace [hostname] with your computer IP/name that act as your webserver, and replace [password]  with your password that set at the beginning.

For doing some testing, you can try the following command (command prompt) at your computer that act as webserver :

telnet 3306 <enter>

Note : if you don’t see the message that the computer (hosted mysql database)  refuse your connection directly, it means your connection to that mysql database can be established.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: