Home > Database > Mysql Tutorial > body text

How Do I Connect MySQL Workbench to a MySQL Instance Running in Docker?

Linda Hamilton
Release: 2024-11-23 14:09:17
Original
796 people have browsed it

How Do I Connect MySQL Workbench to a MySQL Instance Running in Docker?

Connecting MySQL Workbench to MySQL Running Inside Docker

In docker environments, connections to MySQL instances running inside containers are restricted for security reasons. By default, only localhost connections are allowed. To connect from MySQL Workbench on your local machine, follow these steps:

Modifying MySQL Configuration

  1. Create a docker container with the required port mappings.
  2. Obtain the MySQL root password from the container's logs (if this is a fresh installation).
  3. Execute a mysql client to connect directly to the MySQL instance.
  4. Change the root user's host to '%' to allow connections from any host.
  5. Quit the mysql client.
  6. Restart the docker container.

Connecting from MySQL Workbench

After modifying the MySQL configuration, you can connect to the instance from MySQL Workbench using:

  • Host: 0.0.0.0
  • Port: 3306

Note: This configuration allows any host to connect to the MySQL instance, which may not be suitable for production environments. For increased security, you can specify specific hosts or use additional authentication methods.

The above is the detailed content of How Do I Connect MySQL Workbench to a MySQL Instance Running in Docker?. 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