How Do I Configure MySQL for Remote Access?

Linode Staff

I want to be able to remotely access the MySQL on my Linode. How can I configure this?

3 Replies

Hey there!

MySQL, under its default installation, will allow you to remotely access it. What you may run into, however, is remotely accessing MySQL with root access. If this is something you want to enable, run this SQL command on the Linode:

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

You will also then want to access the configuration file typically found at /etc/mysql/my.cnf and comment out the line that says bind-address = 127.0.0.1'. To clarify, you do this by adding a # in front of the line so it reads#bind-address = 127.0.0.1'.

It is possible you will need to reset all the root passwords for MySQL as well. You do this by running the following command while logged into your Linode by running the following commands:

use mysql;
update user set password=PASSWORD("NEWPASSWORD") where User='root';
flush privileges;

Make sure to restart MySQL. After you have done this, you can check to make sure MySQL is listening on port 3306 by running either netstat -plunt or ss plunt depending on your distribution. You will likely see a result that includes the following:

tcp        0      0 0.0.0.0:3306          0.0.0.0:*               LISTEN      <PID>/mysqld

I hope this helps!

How can I run these SQL Command from my windows client machine?

Currently I am using putty, but when I tried to run the commands, the problem has not resolved.

When you log in to the server using PuTTY try running this command

$ mysql -u root -p

MySQL will prompt you for the MySQL root password and then you should get a command line where you can run SQL statements.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct