If you have installed MySQL server fresh, the MySQL server binds on local loopback address (i.e., by default and
if you would like to access the local MySQL server from any external host, you can allow remote access to MySQL server as follows.
Granting access to a user from a remote host is fairly simple and can be accomplished from just a few steps.
This tutorial will walk you through setting up a user on your MySQL server to connect remotely.

Step 1 : vi /etc/my.cnf
pid-file = /var/run/mysqld/mysqld.pid

socket = /var/run/mysqld/mysqld.sock

port = 3306

basedir = /usr

datadir = /var/lib/mysql

tmpdir = /tmp

language = /usr/share/mysql/English

bind-address = mysql server ip

# skip-networking


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 removed from file or put it in comment state.

Step 2 : /etc/init.d/mysql restart

Step 3 : Grant access to remote IP address

mysql -u root -p mysqlGrant access to new database

Step 4 : If you want to add new database aaa for user bbb and remote IP xxx.xxx.xxx.xxx then type following commands at mysql prompt:

mysql> GRANT ALL ON aaa.* TO bbb@’xxx.xxx.xxx.xxx’ IDENTIFIED BY ‘PASSWORD’;

Step 5 : Grant access to existing database

mysql> update db set Host=’xxx.xxx.xxx.xxx’ where Db=’webdb’;
mysql> update user set Host=’xxx.xxx.xxx.xxx’ where user=’webadmin’;

mysql> exit

Step 6 : Test it From remote system

mysql -u webadmin –h –p


Thats all….:)



Leave a Reply

Your email address will not be published. Required fields are marked *