For my PhD project I have elected to deploy a Mysql server to store data, but I don’t want to install it directly on my Mac. Various reasons for this but mainly as I need to be able remove it cleanly when I finished. I’ve used Docker before as it allows service daemons to be deployed and remove very easily – no worries about the correct versions of supporting libraries … bliss
Unless you’ve got Docker installed on your computer then, you’ll need to download and install it. A lot has happened, politically, since I originally did this so I’m just going to refer to the download location that I tend to use: https://www.docker.com/community-edition
Follow your normal processes to download and install the software, and ensure that it is running.
When installing new containers; you ask Docker to run them, it checks to see if there is a local image and if not it downloads it. It then starts the image on your host computer.
When installing the MySQL Server Docker I would not recommend running on the default port (3306) as it may get in the way if either you do install a full MySQL server on your computer or deploy multiple instances. In this example I will use port 6603 as I can easily remember it, I think that the default port used by the Docker installer, is 33060.
To install I used the following:
$ docker run —name mysql -e MYSQL_USER=user -e MYSQL_PASSWORD=pass \
-e MYSQL_DATABASE=db1 -p 6603:3306 -d mysql/mysql-server
This will download the latest Docker image for mysql/mysql-server, into the local repository. It will start up the instance, create the database ‘db1‘ and setup the user ‘user‘ with a password of ‘pass’. To access the server you need to either install the mysql client software, or a client application, and connect to TCP port 6603 (or whatever you selected, on ‘localhost‘ or ‘127.0.0.1’.
If you have SQL scripts I would suggest installing the command line version of MySQL client. That was my approach, but I would also suggest looking at an application, as they tend to let you tinker with the databases in a more intuitive way.
My preferred application is ‘Sequel Pro’ – it was easy to get used to and has the best combination of capabilities. That said, I did stuggle with creating SSL/TLS connections …
Update: Sequel Pro has no support for ‘caching_sha2_password.so’, which appears to be the default in MySQL 8.0 and onwards. I have now switched to using TablePlus which does not have this restriction.