Home > Database > Mysql Tutorial > body text

How to Connect MySQL Workbench to a Dockerized MySQL Instance?

Patricia Arquette
Release: 2024-11-24 04:04:14
Original
334 people have browsed it

How to Connect MySQL Workbench to a Dockerized MySQL Instance?

Overcoming MySQL Connectivity Issues with Docker and MySQL Workbench

Running MySQL within a Docker container can sometimes present connectivity challenges when accessing it from a local MySQL Workbench. This article delves into the solution to this problem.

Understanding the Connection Barrier

By default, MySQL imposes connection restrictions, limiting access to localhost connections only. This prevents external connections, including those from MySQL Workbench running on the host machine.

Allowing Root Access from All Hosts

To enable root access from all hosts:

  1. Start the MySQL Container:

    docker run -p 3306:3306 --name=mysql57 -d mysql/mysql-server:5.7
    Copy after login
  2. Get the Default Password:

    docker logs mysql57 2>&1 | grep GENERATED
    Copy after login
  3. Connect to MySQL:

    docker exec -it mysql57 mysql -uroot -p
    Copy after login
  4. Alter User Settings:

    update mysql.user set host = '%' where user='root';
    Copy after login
  5. Restart the Container:

    docker restart mysql57
    Copy after login

Connecting from MySQL Workbench

Now, you can connect to MySQL from MySQL Workbench using the following parameters:

host: `0.0.0.0` 
port: `3306`
Copy after login

The above is the detailed content of How to Connect MySQL Workbench to a Dockerized MySQL Instance?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template