In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Docker MySQL stores the data in a local directory, which is simple. You only need to map the local directory to the container.
1. Add the-v parameter
$docker run-d-e MYSQL_ROOT_PASSWORD=admin-- name mysql-v / data/mysql/data:/var/lib/mysql-p 3306 data/mysql/data:/var/lib/mysql 3306 mysql
You can also specify a profile
Docker run-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 name mysql 3306 mysql
In this way, the configuration file can be modified, and the data can be stored in the local directory, killing two birds with one stone. The-v parameter can be used multiple times, one directory at a time. In this way, it is easy to configure.
Docker run-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 name mysql-- lower_case_table_names=1
The explanation is as follows:
-d container runs in the background
-e MYSQL_ROOT_PASSWORD=admin configure the password for mysql root
-v map the configuration file and data storage path of mysql to the host, and persist the data
-p port mapping
-- name defines the name of the container
-- the lower_case_table_names=1 definition database is not case-sensitive
Steps for netizens:
Pull mysql image
Docker pull mysql
Run mysql
Docker run
-- net=host
-- restart=always
-- privileged=true
-v / usr/docker_dat/mysql/data:/var/lib/mysql
-- name mysql
-p 3306 Suzhou 3306
-e MYSQL_ROOT_PASSWORD=root
-v / etc/localtime:/etc/localtime:ro
-d mysql-- lower_case_table_names=1
3. Parameter description
-- restart=always starts with docker
-- privileged=true container root user has host root user rights
-v map the host path to the container
-e MYSQL_ROOT_PASSWORD=root sets the root user password
-d background start
-- lower_case_table_names=1 sets table names, parameter names, etc. to ignore case
-v / etc/localtime:/etc/localtime:ro sets the time of the container to synchronize with the host
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.