MySQL之修改max_connections

注意:MySQL版本是5.7,操作系统是Ubuntu16 64位操作系统。

1.在/etc/security/limits.conf文件末尾加上如下内容

    List-1

* hard nofile 65535
* soft nofile 65535

2. 拷贝mysql.service,之后编辑

    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

3.编辑/etc/mysql/my.cnf,加入List-4中的内容

    List-4

[mysqld]
max_connections=600

4.执行命令

    List-5

sudo systemctl daemon-reload

5.重启MySQL之后,查看performance_schema数据库,

    查看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)

 

Reference:

    1.https://www.digitalocean.com/community/questions/max_connections-will-not-change-in-ubuntu,途中遇到了一些问题,参考了这个链接的内容。

 

转载于:https://my.oschina.net/u/2518341/blog/1831276

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值