Modify the maximum number of connections for docker deployment mysql (including Rancher deployment)

1. Native docker startup method

Add variables at the end of the docker start command--max-connections=1000

docker run -d -p 3306:3306 --name mysql \
  -e MYSQL_ROOT_PASSWORD=xxx \
  mysql:5.7.38 \
  --max-connections=1000

2. How to start Rancher

Add in the [command (CMD)] of the workload configuration--max-connections=1000

insert image description here

3. Verification

mysql> show variables like '%max_connections';
+-----------------+-------+
| Variable_name   | Value |
+-----------------+-------+
| max_connections | 1000  |
+-----------------+-------+
1 row in set (0.01 sec)

4. Epilogue

When encountering this problem, first of all, Baidu, which seems to be a lot of articles, opens almost all of them to enter the container to modify the configuration file, and then restart the container service. Is this…reasonable? After the container is restarted, the non-persistent directory will be restored. The modified configuration file path is /etc/mysql/mysql.conf.dbelow, and the persistent directory is /var/lib/mysqlso the modified content does not exist after restarting!

In addition to configuring the maximum number of connections, there are many parameters that can be configured in this way, which can be viewed through the following command:

docker run -it --rm mysql:5.7.38 --verbose --help

Guess you like

Origin blog.csdn.net/qq12547345/article/details/128236270