Running an Ad-Hoc MySQL Instance Locally with Docker

This note was updated on 26 May, 2024 at 09:28.

For some reason I am incapable of committing the following to memory:

$ docker run --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root -d mysql
$ docker exec -it mysql mysql -uroot -p

Adding --restart=unless-stopped to the docker run command will make the MySQL instance persist after a system restart or shutdown.