docker安装mysql
- 拉取镜像
docker pull mysql:5.7 - 启动容器中的mysql
docker run -p 3306:3306 --name mysql01 \
-v /zp/apps/docker_mysql/mysql01/conf:/etc/mysql/conf.d \
-v /zp/apps/docker_mysql/mysql01/data:/var/lib/mysql \
-v /zp/apps/docker_mysql/mysql01/log:/var/log/mysql \
-e MYSQL_ROOT_PASSWORD=wqDcP4k9L6mEOMIk \
-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_general_ci'
init_connect='SET NAMES utf8'
character-set-server=utf8
collation-server=utf8_general_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
配置docker重启,容器自动启动
docker update kaka-redis --restart=always
docker update kaka-mysql --restart=always
如果上边不行,用这个
https://cloud.tencent.com/developer/article/2033919