Allow mysql to access anywhere at port 3306 in ubuntu

When you install MySql server on ubuntu then it is not assessable from any client tool like MySql Workbench or Datagrip. To allow access in mysql to access from anywhere you need to change some configuration in MySql Server.

First of all let me tell you how to install MySql Server on Ubuntu.

Step 1. Login on Ubuntu Server using SSH.

Step 2. Update apt-get.

sudo apt-get update
sudo apt-get install apache2

Step 3. Install MySql

sudo apt-get install mysql-server

Step 4. Start MySql Server

sudo service mysql start


Now you have insalled and rurring MySql. Default username is "root" and password is blank. Let us now allow server to open port 3306.

If you are on cloud hosting then allow port 3306 from Security Group (Inbound rule)



Port Range



After updating Security group go in SSH and update firewall.

sudo ufw allow 3306/tcp

Now your Ubuntu Server is ready to listen at port 3306.

In next step you need to update MySql Configuration.

Step 1. Open configuration file.

sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf

Step 2. Update bind-address     = to

bind-address            =

Step 3. Save (ctrl + o then ctrl+x) and restart MySql Server.

sudo service mysql restart

Now MySql Server is allowed to listen fron anywhere but you have only one user root that is not allowed remote access. Let us create a new user in mysql with remote access.

Step 1. Login on MySql Server.

sudo mysql -u root

Step 2. Create user in mysql server.

mysql> CREATE USER 'username'@'%' IDENTIFIED BY 'xxxxxxxx';
mysql> GRANT ALL PRIVILEGES ON * . * TO 'username'@'%';

Now your MySql Server is ready to connect from anywhere by your username and password.

You can manage your databases by PhpMyAdmin now.

For any other assistance you can contact at: