docker安装mysql

docker中安装mysql

1、切换到root用户

su root

2、运行

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=root \

> -d mysql:5.7


3、设置mysql字符编码

在/mydata/mysql/conf/

新建vi my.cnf

[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

4、

你可能感兴趣的:(docker安装mysql)