14 November 2021

Allow remote connection to MySQL server

Summary
This post shows what command to run if you want the remote devices to be able to connect to your MySQL server on a Linux server such as Ubuntu.

Run the command below in the MySQL CLI.

Note:

  1. Change 'monty' to your own username.
  2. Change some_pass to a secure password.
> CREATE USER 'monty'@'localhost' IDENTIFIED BY 'some_pass';
> GRANT ALL PRIVILEGES ON *.* TO 'monty'@ 'localhost WITH GRANT OPTION;
> CREATE USER 'monty'@'%' IDENTIFIED BY 'some_pass';
> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'%' WITH GRANT OPTION;
> CREATE USER 'admin'@'localhost';
> GRANT RELOAD,PROCESS ON *.* TO 'admin'@'localhost';
> CREATE USER 'dummy'@'localhost';

Next, update the content inside '/etc/mysql/conf.d/mysql.cnf' file by setting bind-address to this value:

bind-address = 0.0.0.0