Launching MySQL with Docker
Install and start Docker. If you’re on Mac, you can download and install Docker Desktop (https://www.docker.com/products/docker-desktop). Note that you’ll need to create a Docker account.
Create a Docker project directory for your mysql container. Name it something like ~/docker/mysqldb
In that directory, create a file called docker-compose.yml. Its contents should contain
services: db: image: mysql environment: MYSQL_ROOT_PASSWORD: 'fill-this-in' ports: - '3306:3306'
The root password provided is the password to the root mysql account. Under ports, you map port 3306 in the Docker container to port 3306 on your local machine.
4. In the same directory, run docker compose up -d
. This will launch a Docker container running your MySQL server.
Now you can connect to the instance as normal using mysql command line or MySQLWorkbench. (Note that mysql clients before 8.0 can't connect to mysql 8.0+)