赞
踩
整理Mysql "Too many connections" 解决办法_Curry_liang-CSDN博客
为了防止发生too many connections时候无法登录的问题,mysql manual有如下的说明:
mysqld actually allows max_connections+1 clients to connect. The extra connection is reserved for use by accounts that have the SUPER privilege. By granting the SUPER privilege to administrators and not to normal users (who should not need it), an administrator can connect to the server and use SHOW PROCESSLIST to diagnose problems even if the maximum number of unprivileged clients are connected.
因此, 必须只 赋予root用户的SUPER权限,同时所有数据库连接的帐户不能赋予SUPER权限。前面说到的报错后无法登录就是由于我们的应用程序直接配置的root用户
查看当前数据库的所有用户:
select user,host,password from mysql.user;
给用户赋予super权限(super和ALL PRIVILEGES都可以):
GRANT super ON *.* TO 'mysql'@'localhost';
GRANT ALL PRIVILEGES ON *.* TO 'mysql'@'localhost';
删除用户的super权限(super和ALL PRIVILEGES都可以):
REVOKE super ON *.* FROM 'mysql'@'localhost';
REVOKE ALL PRIVILEGES ON *.* FROM 'mysql'@'localhost';
查看赋予用户的权限
SHOW GRANTS FOR 'mysql'@'localhost';
微信扫一扫:关注我个人订阅号“猿小飞”,更多精彩文章在这里及时发布:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。