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@’192.168.1.3′ 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 192.168.1.3.now the from the host which ip address is 192.168.1.3 can access to the tutorial_database of the server which give this permission.

mysql

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.

mysql2

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.

mysql3

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

mysql4

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

This code at 50.87.5.175 server:

50.87.5.194=which server i need to access

or

192.168.1.231=”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 *