Allow access from remote host to mysql server

I have a mysql server and wanted to grant access to some remote hosts. The server runs on RedHat Enterprise Linux.

Fir I had to make some changes to the mysql config file:

su
# edit mysql config file
vi /etc/my.cnf
# add the following line
bind-address=SERVER-IP
# make sure there is line that tells mysql which port to use, something like
port=3306
# and that the following line is uncommented, although I did not have this line at all in my my.cnf
# skip-networking

Restart mysql

/etc/init.d/mysqld restart 

Log on to your database an allow access from remote hosts

mysql -u root -p DB -h localhost
GRANT ALL ON MY_DB.* TO 'MY_USER'@'SERVER_IP' IDENTIFIED BY 'MY_PASSWORD';
exit;

Finally check whether or not port 3306 is actually open. If its closed open it with:

su
vi /etc/sysconfig/iptables
# add the following line
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
# save and quit and restart iptables
service iptables restart

Links I found useful:

Advertisements
This entry was posted in mysql. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s