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
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.d
below, and the persistent directory is /var/lib/mysql
so 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