- 拉取镜像
docker pull mysql:5.7 - 启动容器中的mysql
docker run -p 3306:3306 --name kaka-mysql -v /kaka-data/mysql/log:/var/log/mysql -v /kaka-data/mysql/data:/var/lib/mysql -v /kaka-data/mysql/conf:/etc/mysql -e MYSQL_ROOT_PASSWORD=root -d mysql:5.7
- 在sqlyog中测试mysql是否安装成功
- 修改mysql配置
- cd /kaka-data/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
-
重启mysql docker restart kaka-mysql
-
检测刚才的my.cnf是否配置成功
docker exec -it kaka-mysql /bin/bash
cd /etc/mysql
cat my.cnf