当前位置:网站首页>Docker installing MySQL

Docker installing MySQL

2022-06-11 20:33:00 cpuCode

docker operation

https://blog.csdn.net/qq_44226094/article/details/120624387

install MySQL

Pull MySQL

sudo docker pull mysql:5.7

function MySQL

  • –name Specify container name
  • -v Directory mount
  • -p Specify port mapping , The container of 3306 Port mapping to host's 3306 port
  • -e Set up mysql Parameters MYSQL_ROOT_PASSWORD : initialization root The user's password is
  • -d Background operation
sudo docker run -p 3306:3306 --name mysql \
-v /mydata/mysql/log:/var/log/mysql \
-v /mydata/mysql/data:/var/lib/mysql \
-v /mydata/mysql/conf:/etc/mysql \
-e MYSQL_ROOT_PASSWORD=cpucode \
-d mysql:5.7

Get into MySQL

docker exec -it mysql bin/bash

sign out

exit

Because there are directory mappings , So we can execute directly outside the image

vim Modify the configuration file

vim /mydata/mysql/conf/my.conf 

 Insert picture description here

Set up MySQL Parameters

[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
[mysqld]
init_connect='SET collation_connection = utf8_unicode_ci'
init_connect='SET NAMES utf8'
character-set-server=utf8
collation-server=utf8_unicode_ci
skip-character-set-client-handshake
skip-name-resolve

Dokcer restart MySQL service

docker restart mysql

 Insert picture description here

Set up along with docker Start autorun

docker update mysql --restart=always

 Insert picture description here

原网站

版权声明
本文为[cpuCode]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/03/202203011746390716.html