Home > Database > Mysql Tutorial > body text

mysql 1040错误提示Too many connections的解决方法

WBOY
Release: 2016-06-07 17:52:14
Original
3800 people have browsed it

最简单的办法是因为你的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

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template