mysql 1040_解决CentOS服务器:mysql 1040 too many connections问题(亲测有用)

方法一:

1、mysql -u root -p 回车输入密码进入mysql

[root@root ~]# mysql -u root -p

Enter password:

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 135

Server version: 5.1.73 Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

2、查看现在MYSQL的最大链接数,执行:show variables like “max_connections”;

mysql> show variables like "max_connections";

+-----------------+-------+

| Variable_name | Value |

+-----------------+-------+

| max_connections | 151 |

+-----------------+-------+

1 row in set (0.01 sec)

我们这里可以看到:MYSQL的最大链接数才151,

3、修改MYSQL的最大链接数,执行:set GLOBAL max_connections=10000;

mysql> set GLOBAL max_connections=10000;

mysql>

4、再执行:show variables like “max_connections”;看看MYSQL的最大链接数有没有修改成功:

mysql> show variables like "max_connections";

+-----------------+-------+

| Variable_name | Value |

+-----------------+-------+

| max_connections | 10000 |

+-----------------+-------+

1 row in set (0.01 sec)

我们这里可以看到:MYSQL的最大链接数才10000了,退出就可以了

5、exit退出,这种方法弊端就是每次重启服务器后都需要修改MYSQL的最大链接数

方法二:

1、修改mysql配置文件my.cnf:vim /etc/my.cnf

[mysqld]

port = 3306

socket = /var/lib/mysql/mysql.sock

skip-external-locking

key_buffer_size = 160M

max_allowed_packet = 100M

table_open_cache = 256

sort_buffer_size = 512K

net_buffer_length = 8K

read_buffer_size = 256K

read_rnd_buffer_size = 512K

myisam_sort_buffer_size = 80M

skip-grant-tables

lower_case_table_names=1

max_connections=10000

# Don't listen on a TCP/IP port at all. This can be a security enhancement,

# if all processes that need to connect to mysqld run on the same host.

找到:max_connections=151,修改为:max_connections=10000 (如没有就在[mysqld]下自行添加)

2、:wq保存退出

3、重新启动mysql:service mysql restart

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值