Remote Database Access | Web Programming Tutorial

Remote Database Access

Published Date: October 15, 2013 |
Published Time: 8:42 pm |

Some times we need to access database which is not at  same server, it’s may locate on remote host, or at other server in local area network.

If we want to connect this Remote database server, we can’t do it directly what we usually do for our local server. You have to need permission to access the remote database.

To connect with database we need 3 parameters  , host name or ip address, database username, user password.

At Php we make connection to mysql that way

To connect at remote server, the procedure is same, difference is that,  remote server have to have a permission that, this ip(your ip) or this host(your host) can access the database remotely. Then you can access the database from your server.

How to give permission for remote access:

To give remote access privilage we can use command line or phpmyadmin interface. And at Cpanel there is option to give permission of remote access.

Command line in remote database sever : c:>xampp>mysql>bin>mysql -u root -p

mysql> GRANT ALL ON tutorial_database.* TO konok@’′ IDENTIFIED BY ‘password’;

this query need to modify at ip address to “konok-PC” or my pc name or change host from user at “any HOST”
This statement will grant ALL permissions to the newly created user konok with a password of ‘password’ when they connect from the IP address the from the host which ip address is can access to the tutorial_database of the server which give this permission.


With phpMyAdmin at remote database server:

Go to phpmyadmin.Click on specific databse( example : board_attendance database).Then click on Privilages on the top menu. and then click action of user. Change the login information at Host: field. Write here the ip address from where this database can be accessed. if you want to give permission to all remote host, % symbol be used.


Give permission to Cpanel:

Most of the Cpanel has “Remote Mysql” option.Click on Remote Mysql option and then insert the ip address or host name from where , or who can access your database server.


The ip address(  of the sever from which this can be accessed.


Connect to the Remote Server: Now we can connect to from easily by normal procedure.

This code at server: server i need to access

or”alamin pc’s Ip adress” in local area network . You can find it by ipconfig command in command promt

Leave a Reply

Your email address will not be published. Required fields are marked *