"If a worker wants to do his job well, he must first sharpen his tools." - Confucius, "The Analects of Confucius. Lu Linggong"
Front page > Programming > How Can I Connect MySQL Workbench to a MySQL Server Running in Docker?

How Can I Connect MySQL Workbench to a MySQL Server Running in Docker?

Posted on 2025-03-23
Browse:884

How Can I Connect MySQL Workbench to a MySQL Server Running in Docker?

Connecting MySQL Workbench to MySQL Running in Docker

MySQL by default imposes connection restrictions for security reasons. To allow for external connections, such as from MySQL Workbench, specific modifications are required.

Connection Setup

  1. Start the MySQL Docker image with the required port mappings, for example:
docker run -p 3306:3306 --name=mysql57 -d mysql/mysql-server:5.7
  1. Obtain the default password if it's a fresh installation:
docker logs mysql57 2>&1 | grep GENERATED
  1. Connect to the mysqld in Docker using the mysql client:
docker exec -it mysql57 mysql -uroot -p
  1. Change the password and run the following SQL statement:
update mysql.user set host = '%' where user='root';
  1. Quit the mysql client and restart the Docker container:
docker restart mysql57

Workbench Connection

You can now connect to MySQL from MySQL Workbench using the following parameters:

  • Host: 0.0.0.0
  • Port: 3306

After these modifications, the connection restrictions will be lifted, allowing access to MySQL from external hosts, including MySQL Workbench.

Latest tutorial More>

Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.

Copyright© 2022 湘ICP备2022001581号-3