Thursday 19 January 2012

Allowing Remote Access to a MySQL Database

By default MySQL does not allow databases in a machine to be accessed from a remote host. By performing the following steps, access to a database from a remote machine can be enabled.


Connect to the mysql server :

[root@localhost:~] mysql -u <username> -p



Now for  Granting access to the IP address of the remote machine :

mysql>   GRANT ALL ON dbname.*  TO  username@'IP ADDRESS' IDENTIFIED BY 'PASSWORD';



Along with this you will need to allow Port 3306 to be accessed by the remote machine.

If Iptables is used,

iptables -A INPUT -p tcp --dport 3306 -j ACCEPT



This will allow the user to access the database from a remote machine.



No comments:

Post a Comment