Search This Blog

Sunday, June 06, 2010

Enable remote Mysql Procedure.

Enable remote Mysql Procedure.

1. Login to the server.
2. Edit /etc/my.cnf file (vi /etc/my.cnf)
3. Comment the Line Skip-networking or delete the Line
4. bind-address = Give the IP of the remote server.
bind-address : IP address to bind to
skip-networking : Don’t listen for TCP/IP connections at all. All interaction with mysqld must be made via Unix sockets. This option is highly recommended for systems where only local requests are allowed. Since you need to allow remote connection this line should be removed from my.cnf or put it in comment state.
5. Save the file and restart the service Mysql.
6. Grant access t the database
Eg :

mysql> CREATE DATABASE bvs;
mysql> GRANT ALL ON bvs.* TO bar@'IP address' IDENTIFIED BY 'PASSWORD';

7. If you want to Grant Access To An Existing Database?

Eg:

mysql> update db set Host='IP address' where Db='Database Name';
mysql> update user set Host='IP address' where user='Database User';

8. Open the port 3306 In the firewall
Eg : If you are using iptables.

iptables -A INPUT -i eth0 -p tcp --destination-port 3306 -j ACCEPT

only allow remote connection from your web server located at Particular IP address

iptables -A INPUT -i eth0 -s 10.5.1.3 -p tcp --destination-port 3306 -j ACCEPT

only allow remote connection from your lan subnet 192.168.1.0/24

iptables -A INPUT -i eth0 -s 192.168.1.0/24 -p tcp --destination-port 3306 -j ACCEPT

Save the IP tables and restart.

No comments: