mysql ERROR 1040: Too many connections
发布:smiling 来源: PHP粉丝网 添加日期:2014-10-02 16:35:58 浏览: 评论:0
今天早起打开网站发现动态页面居然显示了ERROR 1040:Too many connections提示了,这不是连接过多的原因吧,我一个博客一天没几个IP呀,怎么会这样立即上vps查看.
错提示如下:
#/home/binbin.zhengbb/ssh/update_dns.sh
ERROR 1040 (08004): Too many connections
ERROR 1040 (08004): Too many connections
出现此错误的原因,一种是访问量确实很高,MySQL服务器顶不住,这个时候就要考虑增加从服务器分散读压力,另外一种情况是MySQL配置文件中max_connections值过小.
查询MySQL的最大连接数,代码如下:
- mysql> show variables like 'max_connections';
- +-----------------+-------+
- | Variable_name | Value |
- +-----------------+-------+
- | max_connections | 100 |
- +-----------------+-------+
- 1 row in set (0.00 sec)
查询MySQL响应的最大连接数,代码如下:
- mysql> show global status like 'max_used_connections';
- +----------------------+-------+
- | Variable_name | Value |
- +----------------------+-------+
- | Max_used_connections | 5 |
- +----------------------+-------+
- 1 row in set (0.00 sec)
说明:本地环境没什么参考价值,但是就上面的数据而言,MySQL过去所响应的最大连接数小于其允许的最大连接数,所以不会出现1040错误.
MySQL比较理想的最大连接数计算方式为:
max_used_connections / max_connections * 100% ≈ 85%
即最大连接数占上限连接数的85%左右,如果发现比例在10%以下,MySQL服务器连接数上限设置的过高了.
方法一:直接修改mysql,代码如下:
- mysql> show variables;
- | max_connections | 100
- mysql> set GLOBAL max_connections=1500;
方法二:修改配置文件,代码如下:
- [Intranet root@inc-dp-149-47 /root]
- #vi /etc/my.cnf
- [mysqld]
- datadir=/var/lib/mysql
- socket=/var/lib/mysql/mysql.sock
- user=mysql
- # Default to using old password format for compatibility with mysql 3.x
- # clients (those using the mysqlclient10 compatibility package).
- old_passwords=1
- log-bin=/var/lib/mysql/mysql_bin_log/log-bin
- expire_logs_days=7
- log-slow-queries=/var/log/mysqld_slow_query.log
- set-variable=max_connections=1500
- [mysqld_safe]
- log-error=/var/log/mysqld.log
- #log-update=/var/log/mysqld_update.log
- pid-file=/var/run/mysqld/mysqld.pid
最后重启我们的mysql数据库服务器就可以了.
Tags: ERROR1040:Too many connections
相关文章
- ·Mysql "Too many connections"错误解决办法(2014-09-24)
- ·MySQL连接too many connection错误并且启动时间特别长(2014-10-04)
- ·Mysql “Too many connections” 的解决方法(2014-10-04)
- ·LInux网站提示“Too many connections”的解决方法(2014-10-09)
- ·Host ‘XXXXXX’ is blocked because of many connection errors(2014-10-13)
- ·mysql出现too many connections错误提示(2014-10-14)
- ·mysql too many connections(2014-10-17)
- ·MYSQL提示 max_open_files: 2048 max_connections: 800 table_cache: 619(2014-09-23)
- ·ERROR 1040: Too many connections问题解决办法(2014-09-28)
- ·mysql 1040 Too many connections错误(2014-10-08)
- ·mysql 1040错误提示Too many connections的解决方法(2014-10-12)
推荐文章
热门文章
最新评论文章
- 写给考虑创业的年轻程序员(10)
- PHP新手上路(一)(7)
- 惹恼程序员的十件事(5)
- PHP邮件发送例子,已测试成功(5)
- 致初学者:PHP比ASP优秀的七个理由(4)
- PHP会被淘汰吗?(4)
- PHP新手上路(四)(4)
- 如何去学习PHP?(2)
- 简单入门级php分页代码(2)
- php中邮箱email 电话等格式的验证(2)