1.Mysql
1.安装
1.选择5.7版本
docker pull mysql:5.7
2.在宿主机创建共享文件夹
/home/eva/mysql/data
/home/eva/mysql/conf
3.启动mysql容器
docker run --name mysql -p 3306:3306 -v /home/eva/mysql/data:/var/lib/mysql -v /home/eva/mysql/conf:/etc/mysql/conf.d -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:5.7
4.重置root密码
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('root');
5.配置mysql远程可以访问
GRANT ALL PRIVILEGES ON *.* TO root@localhost IDENTIFIED BY 'root' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY 'root' WITH GRANT OPTION;
flush privileges;
2.配置
6.查看mysql最大连接数
mysql> show variables like '%max_connections%';
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| max_connections | 156 |
+-----------------+-------+
1 row in set (0.01 sec)
7.配置mysql配置文件(根据官方说明,mysql配置文件在/etc/mysql/conf.d 目录下)
在宿主机的/home/eva/mysql/conf 目录下创建my.cnf配置文件
添加:
[mysqld]
max_connections = 3000
8.重启mysql容器,并进入mysql容器,查看最大连接数
mysql> show variables like '%max_connections%';
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| max_connections | 3000 |
+-----------------+-------+
1 row in set (0.01 sec)
经过上面的6,7,8步骤,自定义配置文件生效了