Install mysql database under docker

Because with the .net core so I want to learn to use under docker;

Project just to use mysql database, used docker to install once, I'm using version 5.6;

1. Pull official mirror

docker pull mysql:5.6

2. Create a new directory in the current user directory

mkdir mysql

3. Go to the directory and create a new directory conf

mkdir conf

4. Create a temporary directory to map mysql vessel and the conf;

Performed in the mysql directory

docker run --rm --name mysqlTemp -it -v $PWD/conf/:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=123456 mysql:5.6 /bin/bash

5. Copy the file out my.cnf

cp /etc/mysql/my.cnf /var/lib/mysql

If you do not complete the implementation of my.cnf

cp -R /etc/mysql/conf.d/ /var/lib/mysql/conf.d

cp -R /etc/mysql/mysql.conf.d/ /var/lib/mysql/mysql.conf.d

6. Exit container exit

 

7. Modify mysql.conf.d / mysqld.cnf add a line lower_case_table_names = 1 ignore the table name case

A formal database instance container 8. Run

docker run -p 3306:3306 --name ce-mysql -v $PWD/conf/my.cnf:/etc/mysql/my.cnf -v $PWD/conf/conf.d:/etc/mysql/conf.d -v $PWD/conf/mysql.conf.d:/etc/mysql/mysql.conf.d -v $PWD/logs:/logs -v $PWD/data:/var/lib/mysql -e [email protected] -d mysql:5.6

carry out!

Guess you like

Origin www.cnblogs.com/lr215/p/11600631.html