Welcome to the big Data and AI technical articles released by the public number: Qing Research Academy, where you can learn the night white (author's pen name) carefully organized notes, let us make a little progress every day, so that excellent become a habit!
Docker MySQL stores data in a local directory, and it's simple to map a local directory to a container
1. Plus-v parameter
-d -e MYSQL_ROOT_PASSWORD=admin --name mysql -v /data/mysql/data:/var/lib/mysql -p 3306:3306 mysql
You can also specify a configuration file
-d -e MYSQL_ROOT_PASSWORD=admin --name mysql -v /data/mysql/my.cnf:/etc/mysql/my.cnf -v /data/mysql/data:/var/lib/mysql -p 3306:3306 mysql
In this way, you can modify the configuration file, you can also store the data in the local directory, double benefit, the-v parameter can be used multiple times, each mapping a directory, in this manner, it is easy to configure.
Docker MySQL stores data in a local directory