Add remote access to MySQL server

Follow the commands below to setup a new user and open up for remote access to a specific database on your MySQL server.

$ mysql -u root -p
Enter your MySQL root password.
mysql> CREATE USER 'itdb_admin';
mysql> CREATE DATABASE itdb_db;
mysql> GRANT ALL PRIVILEGES ON itdb_db.* to 'itdb_admin'@'%' IDENTIFIED BY 'my-password' WITH GRANT OPTION;
mysql> FLUSH PRIVILEGES;
mysql> EXIT;
$ sudo nano /etc/mysql/my.cnf
Comment the following line by setting a # in front (to disable it):
bind-address = 127.0.0.1
$ sudo service mysql restart

Quick summary:

1) Open the MySQL CLI
2) Create a new database
3) Create a new user
4) Give the user full access to the database. Notice the '%' which means we’re talking about remote access. The same user can have different access levels based on the connection (whether it’s remote or local)
5) Flush/refresh the privileges so they become active
6) Disable bind-address so the MySQL server will listen on any source address
7) Restart the MySQL service to reload the config file

Was this post helpful?
Yes
No
Powered by Pixelbart

One thought on “Add remote access to MySQL server”

  1. We absolutely love your blog and find almost all of your
    post’s to be just what I’m looking for. Does one
    offer guest writers to write content to suit your needs?

    I wouldn’t mind composing a post or elaborating
    on some of the subjects you write about here.
    Again, awesome web site!

Leave a Reply

Your email address will not be published. Required fields are marked *