Debian – Install MySQL with remote root access


mysql_logoA few simple steps to install MySQL with remote root access on a Debian system.  Out of the box, as default, the root user can only log in from localhost. It’s easier to work from your laptop or workstation when your MySQL server is just a console based linux server. Either located on your home network or at a data center.

Login to your server as root, and type:
apt-get install mysql-server

Select your desired root password, and let it finish the installation.
When it’s done, type in:
mysql -u root -p

When you have logged into the MySQL Server, we will need to grant you with remote access rights. Kind of the whole purpose of this anyway.

mysql> GRANT ALL PRIVILEGES ON *.* TO ‘root’@’%’ IDENTIFIED BY ‘your password’ WITH GRANT OPTION;
mysql> FLUSH PRIVILEGES;
mysql> quit

The MySQL server will now accept the root to be logged in from anywhere. But we need to make MySQL to accept connections from outside localhost. This is done by changing the bind in my.cnf. Type in:

vim /etc/mysql/my.cnf       (or you can use any other text editor. To install vim: apt-get install vim)

Locate the line: bind-address = 127.0.0.1
and comment it out by putting a # at the beginning of the line.

For safety I recommend binding it to your ip instead of removing the bind (or actually accept any ip).

Happy developing!

Have any Question or Comment?

Leave a Reply