Home Linux Ubuntu Allow Remote Access to MySQL Database on Ubuntu

Allow Remote Access to MySQL Database on Ubuntu

How can I take remote access to MySQL database on Ubuntu machine??

MySQL db Remote Access

MySQL database is an open-source database. Let us suppose, MySQL database server is at Ubuntu Server and we want to take its remote from our local Linux server. So here we need to allow remote access of MySQL database on the ubuntu server. In this article, we are using MySQL 5.7 version.

Read More: Install MySQL server on Ubuntu

Step 1

Login to MySQL database server with root user or sudo user.

Step 2

By default, MySQL only allows localhost ( to connect with the database server. So we will edit the file /etc/mysql/mysql.conf.d/mysqld.cnf and change the to (any host).

# sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf
mysqld.cnf file outputmysqld.cnf file output

After changing the bind-address to, save the file and restart the MySQL service.

# sudo service mysql restart

Step 3

Next step is to create the MySQL database user to login remotely. For example, you are managing the database name ‘testing’ & user is ‘remoteuser’. You can create the same username for a different host. Here we will create user name ‘remoteuser’ for host from which we will connect the database remotely.
Go to MySQL server, login to MySQL and run the following command:

# CREATE USER 'remoteuser'@'' IDENTIFIED BY 'Arunchandel@123';
# GRANT ALL PRIVILEGES ON testing. * TO 'remoteuser'@'';
# flush privileges;

Where ‘testing’ = Database name
flush privileges = Reload the changes done

Step 4

The final step is to take the remote access of MySQL database.

# mysql -u remoteuser -h -p

where = MySQL database server IP

connect mysql database serverconnect mysql database server

Congratulations !!! You learned how to allow remote access to MySQL database on ubuntu server. For any feedback, write in the comment box.


Please enter your comment!
Please enter your name here