查看最大连接数: show variables like 'max_connect%';

查看当前连接数: show status like 'Threads%';

 

修改mysql的连接数:

 

vim /etc/my.cnf

[mysqld]
#设置编码格式
character-set-server=utf8
#数据存储目录
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
#开启慢查询
slow_query_log =1
#设置慢查询时间,超过2秒就是慢查询
long_query_time = 2
#慢查询日志文件存储路径
slow_query_log_file=/var/run/mysqld/mysqld-slow.log
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# 将默认的连接数改成500
max_connections = 500

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8

 

然后重启mysql : service mysqld  restart ;  (centos6)

 

 

此外,也可以在msqyl命令行中直接设置: 

  set global max_connections = 1000; 

 

posted on 2020-02-13 22:09  显示账号  阅读(340)  评论(0编辑  收藏  举报