New MYSQL installation on host to access from Docker on Ubuntu

sudo apt-get update
sudo apt-get install mysql-server
sudo ufw allow mysql
systemctl start mysql
systemctl enable mysql
/usr/bin/mysql -u root -p
UPDATE mysql.user SET authentication_string = PASSWORD('password') WHERE User = 'root';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
FLUSH PRIVILEGES;

And edit the file /etc/mysql/mysql.conf.d/mysqld.cnf:

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

Comment out bind-address line from this:

bind-address = 127.0.0.1

To this:

#bind-address = 127.0.0.1

Reset the service and it will work!

sudo /etc/init.d/mysql restart

 

Leave a Reply

Your email address will not be published. Required fields are marked *