注意:MySQL版本是5.7,操作系统是Ubuntu16 64位操作系统。
List-1
* hard nofile 65535
* soft nofile 65535
List-2
sudo cp /lib/systemd/system/mysql.service /etc/systemd/system/
sudo vim /etc/systemd/system/mysql.service
在/etc/systemd/system/mysql.service文件末尾加入如下List-3中的内容
List-3
LimitNOFILE=65535
LimitMEMLOCK=65535
List-4
[mysqld]
max_connections=600
List-5
sudo systemctl daemon-reload
查看open_files_limit的值,这个值默认值是1024,我们可以看到这个值变为65535了,如下List-6所示。
List-6
mysql> select * from global_variables where variable_name like "%open_file%";
+-------------------+----------------+
| VARIABLE_NAME | VARIABLE_VALUE |
+-------------------+----------------+
| innodb_open_files | 2000 |
| open_files_limit | 65535 |
+-------------------+----------------+
2 rows in set (0.00 sec)
查看max_connections的值,如下List-7所示,max_connections的变为600了。
List-7
mysql> select * from global_variables where variable_name like "%max_conn%";
+-----------------------+----------------+
| VARIABLE_NAME | VARIABLE_VALUE |
+-----------------------+----------------+
| extra_max_connections | 1 |
| max_connect_errors | 100 |
| max_connections | 600 |
+-----------------------+----------------+
3 rows in set (0.00 sec)
1.https://www.digitalocean.com/community/questions/max_connections-will-not-change-in-ubuntu,途中遇到了一些问题,参考了这个链接的内容。
(adsbygoogle = window.adsbygoogle || []).push({});