Docker MySQL data persisted to local, setting no difference in table name capitalization

Source: Internet
Author: User
Tags docker run

Docker MySQL stores data in a local directory, and it's simple to map a local directory to a container


1. Plus-v parameter


$ docker run-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


Docker run-d-E mysql_root_password=admin --name MYSQL -v/data/mysql/my.cnf:/etc/mysql/my.cnf-v/< C6>data/mysql/data:/var/lib/mysql-p 3306: 3306 MySQL


In this way, the configuration file can be modified, but also to the existence of 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 run-d-E mysql_root_password=admin --name MYSQL -v/data/mysql/my.cnf:/etc/mysql/my.cnf-v/< C2>data/mysql/data:/var/lib/mysql-p 3306: 3306 mysql --lower_case_table_names=1


The explanations are as follows:

-D container runs in the background

-e mysql_root_password=Admin config MYSQL ROOT password

-V maps the MySQL configuration file and datastore path to the host, persisting data

-P Port Mapping

--name define the name of the container

--lower_case_table_names=1 definition database does not differentiate between table name and case


User's steps:


    1. Pull MySQL Image


      Docker pull MySQL


    2. Running MySQL

Docker run

--net=host

--restart=always

--privileged=true

-v/usr/docker_dat/mysql/data:/var/lib/mysql

--name MySQL

-P 3,306:3,306

-E Mysql_root_password=root

-v/etc/localtime:/etc/localtime:ro

-D MySQL--lower_case_table_names=1


3. Parameter description

--restart=always Follow Docker Boot

--privileged=true container root user has host root user rights

-V maps the host path to the container

-e mysql_root_password=root Setting the ROOT user password

-D Background Boot

--lower_case_table_names=1 setting table name parameter names and ignoring case

-v/etc/localtime:/etc/localtime:ro Setting the container time to synchronize with the host


Docker MySQL data persisted to local, setting no difference in table name capitalization

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.