483   MySQL

MySQL最大链接数包括:
1,数据库总共的最大连接数;
2,某个用户的最大链接数;

查看最大连接数


mysql> show variables like "%connection%";
+--------------------------+-------------------+
| Variable_name            | Value             |
+--------------------------+-------------------+
| character_set_connection | gb2312            |
| collation_connection     | gb2312_chinese_ci |
| max_connections          | 512               |
| max_user_connections     | 100               |
+--------------------------+-------------------+
4 rows in set (0.00 sec)

修改方式:
1,临时修改,直接在命令行set,重启mysql后会失效

mysql> set global max_connections = 256;
Query OK, 0 rows affected (0.00 sec)

2,永久修改,通过my.cnf配置文件,重启mysql后才能生效
配置文件的在mysql安装目录下,有好几个示例,包括my-huge.cnf,my-small.cnf等,根据需求选择合适一个
拷贝一份到/etc/目录,重名为my.cnf,在[mysqld]添加以下参数,重启mysql即可


max_connections = 512



Leave a Reply

Your email address will not be published. Required fields are marked *