DEV Community

Alexandre Freire
Alexandre Freire

Posted on

Como liberar acesso remoto do MySql server no Ubuntu

Config file changes are required to enable connections via localhost.

To connect through remote IPs, Login as a "root" user and run the below queries in mysql.


CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';

GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost' WITH GRANT OPTION;

CREATE USER 'username'@'%' IDENTIFIED BY 'password';

GRANT ALL PRIVILEGES ON *.* TO 'username'@'%' WITH GRANT OPTION;

FLUSH PRIVILEGES;
Enter fullscreen mode Exit fullscreen mode

This will create a new user that is accessible on localhost as well as from remote IPs.

Also comment the below line from your my.cnf file located in /etc/mysql/my.cnf

bind-address = 127.0.0.1
Enter fullscreen mode Exit fullscreen mode

Restart your mysql using

sudo service mysql restart
Enter fullscreen mode Exit fullscreen mode

Now you should be able to connect remotely to your mysql.

Solution found on stackoverflow and written by harishannam

Top comments (0)