DEV Community

Alexandre Freire
Alexandre Freire

Posted on

3 1

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

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay