后端MysqlMysql-入门
cmyang1. 简介
2. 安装
2.1 5.7版本安装指令
1 2 3 4 5 6 7 8 9 10 11
| docker run -p 3306:3306 --name mysql5.7 --privileged=true \ -v /home/dockerdata/mysql5.7/conf:/etc/mysql \ -v /home/dockerdata/mysql5.7/logs:/var/log/mysql \ -v /home/dockerdata/mysql5.7/data:/var/lib/mysql \ -e MYSQL_ROOT_PASSWORD=aacopy.cn \ -e TZ=Asia/Shanghai \ -d mysql:5.7 \ --character-set-server=utf8mb4 \ --collation-server=utf8mb4_unicode_ci \ --lower_case_table_names=1 \ --sql_mode="STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION"
|
docker ps 查看是否启动成功
lower_case_table_names标识忽略表大小写
sql_mode取消ONLY_FULL_GROUP_BY
问题:
docker ps 中没mysql的信息,服务没有启动成功
docker ps -a 查看全部内容
找到mysql,查看状态Exited (1) 16 seconds ago
docker logs -f containerid 查看日志
日志信息:Entrypoint script for MySQL Server 5.7.36-1debian10 started.
chown: changing ownership of ‘/var/lib/mysql/‘: Permission denied
解决:权限不足的问题,在启动命令里加上 –privileged=true,现把原来容器中的mysql删掉。docker rm ,再执行下面的命令
2.2 8.0版本安装
安装命令
1 2 3 4 5 6 7 8
| docker run -p 3307:3306 --name mysql8.0 --privileged=true \ -v /home/dockerdata/mysql8.0/logs:/var/log/mysql \ -v /home/dockerdata/mysql8.0/data:/var/lib/mysql \ -e MYSQL_ROOT_PASSWORD=aacopy.cn \ -e TZ=Asia/Shanghai \ -d mysql:8.0 \ --lower_case_table_names=1 \ --sql_mode="STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION"
|
修改最大连接数
1 2 3 4 5 6
| show variables like '%max_connections%';
set GLOBAL max_connections=5000; set GLOBAL mysqlx_max_connections=5000;
|