One of our systems has mysql 5.5 installed. But I need mysql 8.0 as db server.
So I have to start a docker container which run mysql 8.0.
The command is quite simple,
docker run --name mysql80 \
-p 3316:3306 \
-v /data/mysql:/var/lib/mysql \
-e MYSQL_ROOT_PASSWORD=jz*** \
-e TZ=Asia/Shanghai \
--restart always \
-d mysql:8.0
Here I map port 3316 to mysql's 3306, and map persistent store /data/mysql to mysql's /var/lib/mysql.
And '-e TZ=' option is quite important which specifies timezone setting.
I then run the normal mysql command to log into it except a special port 3316.
mysql -uroot -p -P3316 -h127.0.0.1
input the password and we get logged.