TL;DR — On Apple Silicon, force Docker to pull and run the linux/x86_64 image for MySQL 5.7. Here’s the minimal
docker-compose.yml
.
version: "3.7"
services:
db:
platform: linux/x86_64
image: mysql:5.7.35
restart: "no"
environment:
MYSQL_DATABASE: "databasename" # convenience: pre-create a DB
MYSQL_ALLOW_EMPTY_PASSWORD: "true"
MYSQL_USER: "admin_user"
MYSQL_PASSWORD: "password"
ports:
- "3306:3306"
Why this is needed
On Apple Silicon (ARM), some older images (like mysql:5.7.x
) don’t have native ARM builds. By pinning:
platform: linux/x86_64
Docker will pull and emulate the x86_64 image on your M1/M2 machine, which works great for local dev.
Quick start
-
Save the compose file above as
docker-compose.yml
. -
From the same directory, run:
docker compose up
(In IntelliJ/IDEA, you can also right-click → Run on the compose file, or use the Services tool window.)
-
Connect with your favorite client on
localhost:3306
:- user:
admin_user
- password:
password
- db:
databasename
- user:
What the env vars do
MYSQL_DATABASE
– creates a database on container start, so you don’t have to runCREATE DATABASE
.MYSQL_ALLOW_EMPTY_PASSWORD
– lets you start MySQL without a root password (handy for local dev).MYSQL_USER
/MYSQL_PASSWORD
– creates an app user with credentials you control.
Full transcript (from the video)
hello this is for people who are trying
to run the mysql 5.7 in a
m1 mac computer
basically what you need to do is run
the platform to be x8664
and that's how you get around this it's
super easy to run a docker compose in
intellij all you have to do
is right click run
or hit services right here
this will go ahead and run it and go
ahead and create it and start it
you can see this container start
right here
oops
and there it is
you have mysql 5.7 in about two seconds
running on your computer
to further explain the script over here
this mysql database will just create the
database name
mysql allow empty password this is when
you're trying to log in to the server
and ask you for a password
i just allow empty password and you
could just simply get in
then mysql user that's just the actual
user that is granted all access so you
don't have to grant all access to the
user anymore you can just grant the
access
and then my school password which is
just a password for that user
yeah this definitely saves a lot of time
in order to spin up a container whenever
you know you have to
delete and yeah
i hope you enjoy
If you want a more recent image that supports ARM natively, consider mysql:8.x
. For legacy projects pinned to 5.7, the platform override above is the quickest path on Apple Silicon.