Home   >>   MySQL   >>   Enable Remote Access
Enable Remote Access PDF Print E-mail
( 0 Votes )
How To - MySQL
Written by Christian Foronda   
Wednesday, 17 March 2010 13:40

By default, MySQL database server remote access disabled for security reasons. However, some time you need to provide the remote access to database server from home or from web server.

Login over ssh:

First, login over ssh to remote MySQL database server

Enable networking:

Once connected you need edit the mysql configuration file my.cnf using text editor such as vi. In Debian Linux file is located at /etc/mysql/my.cnf

	# vi /etc/my.cnf

Comment the line skip-networking:

	# skip-networking

Add following line:

	bind-address=YOUR-SERVER-IP

For example, if your MySQL server IP is 172.20.5.2 then entire block should be look like as follows:

	[mysqld]
	user = mysql
	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 = 172.20.5.2

	# skip-networking
	....
	..
	....

Where,
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.
Save and Close the file.

Grant access to remote IP address:

	# mysql -u root -p mysql
	
	mysql> CREATE DATABASE foo;
	mysql> GRANT ALL ON foo.* TO username@'remoteip' IDENTIFIED BY 'password';

Test it:

From remote system type command

	$ mysql -u USERNAME -h SERVERIP –p



blog comments powered by Disqus
Last Updated on Wednesday, 17 March 2010 13:46