Bizzard's Hackshop
Always under construction!

Allowing remote access of MySQL database

We @ DayScholars finally managed to arrange a good PC to setup as a centralized server for our code and databases. The server is running a customized Debian Squeeze distribution with MySQL Version 5.1. So the next requirement is to allow MySQL access for all of us. This is how we managed it. You must login as root user or must have root privilege to do this.

Edit the MySQL configuration file, located at /etc/mysql/my.cnf.

We prefer using vim. You can use any others like nano or even gedit.

Find the line:

bind-address =

and comment it, by prefixing # . Now it looks like:

#bind-address =

Restart mysql server for the change to take effect.

$ /etc/init.d/mysql restart

Now, create a MySQL user with host as ‘ANY HOST’  ie ‘%’. You can do it in command line, or use the PhpMyadmin, which is much easier. The newly created user will be able to access the database server from any remote host, within the network or even from internet.

While writing code, use the IP of the system as host in the database connection string. In PHP, it will look like:

mysql_connect(“ip address”, “username”, “password”) or die(‘Error connecting to database server!’);

Thanks to Niyas for figuring this out so fast. 🙂

Tagged with: , , ,

Leave a Reply