當出現如下情況的時候[root@localhost ~]# MySQL ERROR 1040 (00000): Too many connections
請 [root@localhost ~]# service mysqld restart 停止 MySQL: [ 確定 ] 啟動 MySQL: [ 確定 ] [root@localhost ~]# mysql -h127.0.0.1 Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 7 to server version: 4.1.20
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
MySQL> select @@global.max_connections; +--------------------------+ | @@global.max_connections | +--------------------------+ | 100 | +--------------------------+ 1 row in set (0.05 sec)
MySQL> set global max_connections=5000; Query OK, 0 rows affected (0.00 sec)
MySQL> select @@global.max_connections; +--------------------------+ | @@global.max_connections | +--------------------------+ | 5000 | +--------------------------+ 1 row in set (0.00 sec)
其實我覺得應該是set @@global.max_connections=5000; 一開始自己亂打的。貌似5000有點多了…… 之前在google搜了,有人說要改配置文件,然後去改了my.cnf,我表示完全沒用 [root@localhost ~]# cat /etc/my.cnf [mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock # Default to using old password format for compatibility with mysql 3.x # clients (those using the mysqlclIEnt10 compatibility package). old_passWords=1 skip-grant-tables [mysql.server] user=MySQL basedir=/var/lib
[mysqld_safe] err-log=/var/log/mysqld.log pid-file=/var/run/mysqld/MySQLd.pid
max_connection=1000