Add remote access to MySQL server

Posted on 07.10.16   CLI Database Linux MySQL SysAdmin

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 (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

More on ITDB

Get Linux distribution information from terminal


Oracle Universal Installer - Successfully completed with errors


NiceHash hacked?


Change Resize Mode for all VMs in RoyalTS 4


Finding the source for locked AD account from Event Viewer log on Domain controller




Leave a Reply

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