com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Data source rejected establishment of connection, message from server: "Too many connections"


最簡單的辦法是因為你的my.ini中設定的並發連接數太少或者系統繁忙導致連接數被占滿解決方式:打開MySQL安裝目錄打開MY.INI找到max_connections默認是100 .
-
-
實例

WINDOWS解決mysql Errno.: 1040錯誤
XXXX info: Can not connect to MySQL server

User: root
Time: 2004-5-20 3:00pm
Script: /XXXX/XXXX.PHP

Error: Too many connections
Errno.: 1040

An error report has been dispatched to our administrator.


上面錯誤觀點提示


1.可能是mysql的max connections設置的問題
2.可能是多次insert,update操作沒有關閉session,需要在spring里配置transaction支持。

解決:
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"

原因:

因為你的mysql安裝目錄下的my.ini中設定的並發連接數太少或者系統繁忙導致連接數被占滿


解決方式:

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

一定要重新啟動MYSQL才能生效

代碼如下 復制代碼 
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
再開啟選項,成功啟動。


高手優化的MYSQL my.ini的1000人在線配置。

#This File was made using the WinMySQLAdmin 1.4 Tool 
#2004-2-23 16:28:14 
#Uncomment or Add only the keys that you know how works. 
#Read the MySQL Manual for instructions 
[mysqld] 
basedir=D:/mysql 
#bind-address=210.5.*.* 
datadir=D:/mysql/data 
#language=D:/mysql/share/your language directory 
#slow query log#= 
#tmpdir#= 
#port=3306 
set-variable = max_connections=1500 
skip-locking 
#skip-networking 
set-variable = key_buffer=384M 
set-variable = max_allowed_packet=1M 
set-variable = table_cache=512 
set-variable = sort_buffer=2M 
set-variable = record_buffer=2M 
set-variable = thread_cache=8 
# Try number of CPU's*2 for thread_concurrency 
set-variable = thread_concurrency=8 
set-variable = myisam_sort_buffer_size=64M 
#set-variable = connect_timeout=5 
#set-variable = wait_timeout=5 
server-id = 1 
[isamchk] 
set-variable = key_buffer=128M 
set-variable = sort_buffer=128M 
set-variable = read_buffer=2M 
set-variable = write_buffer=2M 
[myisamchk] 
set-variable = key_buffer=128M 
set-variable = sort_buffer=128M 
set-variable = read_buffer=2M 
set-variable = write_buffer=2M 
[WinMySQLadmin] 
Server=D:/mysql/bin/mysqld-nt.exe


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM