MySQL修改最大连接数


使用MySQL时候,遇到如下报错:Can not connect to MySQL server. Too many connections。

解决办法:修改MySQL最大连接数。

1 打开MySQL的配置文件:

vi /etc/my.cnf

2 加入max_connections=500一行(如果有该行,直接修改值即可)。

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html

#需要主从服务器时,放开此处配置 begin
[mysqld]
#log-bin=mysql-bin   
#[必须]启用二进制日志
#server-id=138        
#[必须]服务器唯一ID,默认是1,一般取IP最后一段

#需要主从服务器时,放开此处配置 end
lower_case_table_names=1

[client]
default-character-set=utf8
[mysqld]
character-set-server=utf8
default-time_zone = '+8:00'
max_connections=500

#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.

3 重启MySQL服务:

service mysqld restart

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM