Tags

, ,

If you need to log into your MySQL server from a remore client the following should help you:

Remember to set a secure password and understand how much exposure your MySQL has.

If you didn’t set a root passoword at installation set one now:

mysql -u root
 mysql> SET PASSWORD FOR 'ROOT'@'LOCALHOST" = PASSWORD('new_password');

Now to allow remote logins for the root user

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
 mysql> FLUSH PRIVILEGES;
 

Replace ‘password’ with the password you want to use for the account. The statement above gives root all privileges on all tables and all databases (*.*) from all hosts (%).

If you haven’t enabled MySQL to listen to remote connections you’ll also need to do that my editing the MySQL config.

sudo vi /etc/mysql/my.cnf

If you have a line starting with

skip-networking

Comment it out by placing a # at the start of the line.

The next part is optional. If you want to bind you MySQL installation to a particular IP address on your system, find  or add the line starting with bind-address.

bind-address = x.x.x.x

And replace x.x.x.x with the IP address you wish to use. If you don’t want to bind to a particular address just comment out the line.

If you changed the my.conf file restart MySQL

sudo /etc/init.d/mysql restart
Advertisements