MySQL "too many connections" 錯誤之mysql解決方法

解決方法是修改/etc/mysql/my.cnf,添加如下一行:
set-variable = max_connections=500

或在啓動命令中加上參數 max_connections=500
就是修改最大鏈接數,而後重啓mysql.默認的鏈接數是100,太少了,因此容易出現如題錯誤.
如下是mysql.com網站的相關說明:
If you get a Too many connections error when you try to connect to the mysqld server, this means that all available connections are in use by other clients.

The number of connections allowed is controlled by the max_connections system variable. Its default value is 100. If you need to support more connections, you should restart mysqld with a larger value for this variable.

mysqld actually allows max_connections+1 clients to connect. The extra connection is reserved for use by accounts that have the SUPER privilege. By granting the SUPER privilege to administrators and not to normal users (who should not need it), an administrator can connect to the server and use SHOW PROCESSLIST to diagnose problems even if the maximum number of unprivileged clients are connected. See Section 13.5.4.19, 「SHOW PROCESSLIST Syntax」.

The maximum number of connections MySQL can support depends on the quality of the thread library on a given platform. Linux or Solaris should be able to support 500-1000 simultaneous connections, depending on how much RAM you have and what your clients are doing. Static Linux binaries provided by MySQL AB can support up to 4000 connections.

mysql

1.多是mysql的max connections設置的問題
2.多是屢次insert,update操做沒有關閉session,須要在spring裏配置transaction支持。spring

解決:
1.修改tomcat裏的session 的time-out時間減小爲20,(不是必改項)
2.對處理量大的對數據庫insert或update的操做提供transaction支持.

=======================================
下面的是解決辦法:
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Data source rejected establishment of connection, message from server: "Too many connections"sql

緣由:數據庫

由於你的mysql安裝目錄下的my.ini中設定的併發鏈接數太少或者系統繁忙致使鏈接數被佔滿tomcat

解決方式:session

打開MYSQL安裝目錄打開MY.INI找到max_connections(在大約第93行)默認是100 通常設置到500~1000比較合適,重啓mysql,這樣1040錯誤就解決啦。
max_connections=1000併發

必定要從新啓動MYSQL才能生效ide

CMD->優化

net stop mysql網站

net start mysql

關於改變innodb_log_file_size後沒法啓動mysql的問題

innodb_buffer_pool_size=768M
innodb_log_file_size=256M
innodb_log_buffer_size=8M
innodb_additional_mem_pool_size=4M
innodb_flush_log_at_trx_commit=0
innodb_thread_concurrency=20
以上是對innodb引擎的初步優化, 發現是更新innodb_log_file_size=256M時候出現了問題,只要加上這個就沒法啓動,

後來才知道原來要STOP服務先,而後再刪除原來的文件………
打開/MySQL Server 5.5/data

刪除ib_logfile0, ib_logfile1........ib_logfilen
再開啓選項,成功啓動

相關文章
相關標籤/搜索