Docker install and run the database mysql5.6

1, the new mysql directory under / home directory

  New mysql directory are three directories: conf directory, directory logs, data directory, make these directories under the directory object to the mysql docker mounted.

  The results are as follows:

 

 

 

 

  1.1, then write in the conf in a configuration file my.cnf mysql, the number of which is to configure the port number ah, what mode ah, ah, what how much memory to open

  Configuration reads as follows: This is my copy over the Internet, configure the content restrictions something, did not use the innodb engine configured according to their needs

port= 3306

character-set-server=utf8

performance_schema_max_table_instances=200

table_definition_cache=200

table_open_cache=128

innodb=OFF

default-storage-engine=MYISAM

default-tmp-storage-engine=MYISAM

loose-innodb-trx=0

loose-innodb-locks=0

loose-innodb-lock-waits=0

loose-innodb-cmp=0

loose-innodb-cmp-per-index=0

loose-innodb-cmp-per-index-reset=0

loose-innodb-cmp-reset=0

loose-innodb-cmpmem=0

loose-innodb-cmpmem-reset=0

loose-innodb-buffer-page=0

loose-innodb-buffer-page-lru=0

loose-innodb-buffer-pool-stats=0

loose-innodb-metrics=0

loose-innodb-ft-default-stopword=0

loose-innodb-ft-inserted=0

loose-innodb-ft-deleted=0

loose-innodb-ft-being-deleted=0

loose-innodb-ft-config=0

loose-innodb-ft-index-cache=0

loose-innodb-ft-index-table=0

loose-innodb-sys-tables=0

loose-innodb-sys-tablestats=0

loose-innodb-sys-indexes=0

loose-innodb-sys-columns=0

loose-innodb-sys-fields=0

loose-innodb-sys-foreign=0

loose-innodb-sys-foreign-cols=0

join_buffer_size = 64M

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

 

 

2, and then use mysql download mirror docker, and run:

  Download mysql5.6 version command: docker pull mysql: 5.6

  View downloaded mysql5.6 database:

 

 

 

 

  2.1, run mysql5.6 container:

docker run -p 3306:3306 --name mysql -v /home/mysql/conf/my.cnf:/etc/mysql/cnf.d -v /home/mysql/logs:/etc/mysql/logs -v /home/mysql/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=123456 -d mysql:5.6
c85b684385002b1ea64c61fe1ba5801d41a1d18afa03bb0c86495addc6cfb614
Command a little longer, say at about what it means:
RUN docker -p 3306 : 3306 --name run mysql mysql meaning container, specify the local port 3306 to port 3306 on the internal mapping of docker, - after the name is from the individual named mysql, alias can not afford, then in operation in the docker mysql this container can only be used to operate the vessel id

-v /home/mysql/conf/my.cnf:/etc/mysql/cnf.d said it would before the new / Home / mysql / conf directory my.cnf mysql configuration file to mount the container configuration, in fact, is replaced, so that the container using this configuration

-v / home / mysql / logs: / etc / mysql / logs as a means with the above, so that the use of container / Home / MySQL / logs directory, do not have to default

-v / Home / MySQL / Data: / var / lib / MySQL as with the above meaning

MYSQL_ROOT_PASSWORD = -e 123456   initialize the root user password

MySQL -d: 5.6    indicates that the container daemon running

 

  View docker running container: docker ps

  We can see mysql run successfully:

 

 

  

 

3, after a successful run mysql container into the data to see:

Access to the database command:
docker exec -it c85b68438500 /bin/bash


Enter the account password database command:
mysql -uroot -p


After entering the database, execute sql code displays all current database: Note To add; number and press Enter
show databases;

 

 

 

 

 

 

 

 

Guess you like

Origin www.cnblogs.com/spll/p/11828336.html