App overview screenshotSQL and Database Guides
Try our free SQL Client
Connecting to MySQL
Connecting to Drivers
Installing MySQL
Setting up MySQL
MySQL   >   
Installing MySQL   >   
MySQL and Docker on Mac

How To Install MySQL with Docker on macOS

If you and your team are working on a containerized project, you often need a database to store information. MySQL is one of the most popular database systems available today. In this guide, we’ll walk you through how to install MySQL in your Docker container on macOS(X).

Installing Docker

If you don’t already have Docker, you can download the installer from the Docker website. Alternatively, if you use a command-line package manager like Homebrew, you can install Docker as a cask with:

brew install --cask docker

Run Docker by using the command line or opening When first opened, Docker requires additional permissions to function, so you’ll have to enter your password.

Get the Official MySQL Docker Image

Check out the list of MySQL versions available in docker. To get the latest one, use pull:

docker pull mysql

Note: If you are on an M1 (Apple Silicon Chip) machine, you’ll need to run docker pull --platform linux/x86_64 mysql as there is currently no ARM64 MySQL package available.

Set the Master Password and Run

The MySQL image requires that you supply a root password. You cannot set this in the Docker Desktop GUI and must do so through the command line:

docker run --name my-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=mypassword -d mysql

The -p flag in this command forwards the MySQL server port from Docker to the host machine. In this case, we are not changing the port, so both values will be the same.

Note: If you are on an M1 machine, you’ll need to once again specify --platform linux/x86_64

By running docker ps you should see your MySQL database running.

Create a Database and User (Optional)

If you don’t already have a database and user, you can follow these steps to create them now. First, navigate to your MySQL container in Docker and click the ‘CLI’ button to launch a shell client:

Docker MySQL Container CLI Button

A terminal window should appear. First run mysql -u root -p and enter your specified root password when prompted. Once you reach the MySQL prompt, run the following commands, substituting myDB, myUser and myPassword for your own desired information.

CREATE USER ‘myUser’@’%’ IDENTIFIED BY ‘myPassword’; 

Connect to Your Docker MySQL Database

To connect to your new MySQL database server from an SQL client, you’ll need the following information:

  • IP/Host: If your docker container is deployed on a remote machine or cluster, you run this command to get the IP address:

    docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' YOUR_CONTAINER_NAME 

    Otherwise, if your docker container is deployed on your local machine, your hostname will simply be localhost.

  • Port: Docker will forward the port of your MySQL server to any port specified in the run command (above). This should be 3306 unless otherwise specified.

  • Database: The name of the schema containing your data within the MySQL instance. From our example above, this would be myDB.

  • User: The username of a user granted privileges on the specified database schema. From our example above, this would be myUser.

  • Password: The password for your user, from our example above, this would be myPassword.

In the Arctype connection screen, enter the above information and click Test Connection. If everything is entered correctly, you should see a ‘Successfully connected to MySQL’ message appear at the bottom of the screen:

Arctype Docker MySQL Database connection credentials

After confirming your connection details, press Save!

Get help on databases and SQL. Join our Discord community.