Friday, August 15, 2008

Remote Access To MySQL Database

Configure my.cnf
1. We will need to edit the my.cnf file. I am assuming you are using GNOME, so open the terminal and type sudo gedit /etc/mysql/my.cnf

2. Change the bind-address to your server IP address (not to 127.0.0.1). Example, I found out my server IP is 192.168.30.30 by using the ifconfig command. So here are the changes,
bind-address = 192.168.30.30



3. Be sure to comment out the skip-networking.
# skip-networking

4. Save and close the file.

Create MySQL New User Account
** Assuming to create the superuser having all privileges and accessed from localhost and other host.
5. Open terminal and start the mysql program.

6. Type this:
mysql> GRANT ALL PRIVILEGES ON *.* TO 'some_user’@'localhost'
-> IDENTIFIED BY 'some_password' WITH GRANT OPTION;
mysql> GRANT ALL PRIVILEGES ON *.* TO 'some_user'@'%'
-> IDENTIFIED BY 'some_password' WITH GRANT OPTION;



7. Restart the MySQL server by open the terminal and type sudo /etc/init.d/mysql restart

No comments: