DEV Community

Frastyawan Nym
Frastyawan Nym

Posted on

Create Local MySQL using Docker Run

This is just a rant writing. Because how difficult tutorial out there just to setup this kind of thing. So I'm here to summarize for you (reader) how to get it done.

Simple! Run:

docker run --name mysql-local -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin -d mysql
Enter fullscreen mode Exit fullscreen mode
  • mysql-local: Your container name, feel free to change it.
  • -p 3306:3306: Expose container to localhost, so we can connect with UI (ex: DBeaver).
  • -e MYSQL_ROOT_PASSWORD=admin: root user password, adjust with your preference.
  • -d: Detach mode
  • mysql: Image name

This will automatically pull the image if not pulled yet.

Connecting into interface (or else)

After this, maybe you need to access via UI. Here is the setting:

  • Host: localhost
  • Port: 3306
  • User: root
  • Password: admin

Maybe you will need this

  1. When connecting, maybe you will get error Public Key Retrieval is not allowed. If you are using DBeaver, search for driver properties/setting. Change allowPublicKeyRetrieval = true

Closing

That it and Thank You.

Top comments (0)