Tuesday, July 19, 2011

Connecting to remote MySQL database

MySQL db can be connected from a  remote location. Say at A mysql is running and from B I am trying to connect.
At A I have created a user for remote access like this .
Opened the dos prompt and gone to c:>cd mysql/bin
c:>mysql>cd bin
c:>mysql> mysql --user=root  --password=mypassword
Here welcome message will appear. and then this line of SQL will grant previlage to remote user
grant select,insert,update, delete on db_name.* to user_name IDENTIFIED BY "user_password";
Here if the user has to be given remote access ( say from coumputer B ) then this should be
grant select,insert,update, delete on db_name.* to user_name@B IDENTIFIED BY "user_password";
This will allow remote access to user user_name from computer B.  At computer B the server address can be the IP address of A and the user id and password will be same .

No comments:

Post a Comment