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

 

posted @   ycyzharry  阅读(1124)  评论(0编辑  收藏  举报
编辑推荐:
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构

喜欢请打赏

扫描二维码打赏

支付宝打赏

点击右上角即可分享
微信分享提示