【已解决】mysql连接出错:ERROR 1040 (HY000): Too many connections

连接mysql,结果出错:

?


1

ERROR 1040 (HY000): Too many connections

去修改mysql的配置文件,然后添加:

?


1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

[email protected]:logs# vi /etc/my.cnf

[mysqld]

lower_case_table_names=1

lower_case_table_names=0

lower_case_table_names=1

datadir=/var/lib/mysql

socket=/var/lib/mysql/mysql.sock

max_connections=100

max_user_connections=100

# Disabling symbolic-links is recommended to prevent assorted security risks

symbolic-links=0

# Settings user and group are ignored when systemd is used (fedora >= 15).

# If you need to run mysqld under a different user or group,

# customize your systemd unit file for mysqld according to the

# instructions in http://fedoraproject.org/wiki/Systemd

user=mysql

# Semisynchronous Replication

http://dev.mysql.com/doc/refman/5.5/en/replication-semisync.html

# uncomment next line on MASTER

;plugin-load=rpl_semi_sync_master=semisync_master.so

# uncomment next line on SLAVE

;plugin-load=rpl_semi_sync_slave=semisync_slave.so

# Others options for Semisynchronous Replication

;rpl_semi_sync_master_enabled=1

;rpl_semi_sync_master_timeout=10

;rpl_semi_sync_slave_enabled=1

http://dev.mysql.com/doc/refman/5.5/en/performance-schema.html

;performance_schema

[mysqld_safe]

log-error=/var/log/mysqld.log

pid-file=/var/run/mysqld/mysqld.pid

然后重启mysqld:

?


1

2

3

4

[email protected]:logs# service mysqld restart

Stopping mysqld:                                           [  OK  ]

Starting mysqld:                                           [  OK  ]

[email protected]:logs#

然后重新连接试试,就可以了:

?


1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

[email protected]:logs# mysql -u root -p openfire_schoolike

Enter password:

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 440

Server version: 5.5.44-cll-lve MySQL Community Server (GPL) by Atomicorp

Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.

mysql>

【总结】

当连接mysql时,出现:

ERROR 1040 (HY000): Too many connections

的错误时:

去增加mysql的最大连接数即可:

修改mysql的配置文件:

/etc/my.cnf

在[mysqld]字段中增加配置:

?


1

2

max_connections=100

max_user_connections=100

当然可以根据自己需要,设置更大的值。

然后再重启mysqld:

?


1

service mysqld restart

即可正常连接mysql。

原文地址:https://www.cnblogs.com/weifeng1463/p/10192504.html

时间: 2024-10-11 13:20:16

【已解决】mysql连接出错:ERROR 1040 (HY000): Too many connections的相关文章

Mysql连接数太多ERROR 1040 (HY000): Too many connections

数据库连接报错:ERROR 1040 (HY000): Too many connections 1.查看连接数 /usr/local/mysql/bin/mysqladmin -h host -u root -p123456 status 这条命令返回MYSQL当前状态的几个值 Uptime: 18869  Threads: 1  Questions: 1  Slow queries: 0  Opens: 33  Flush tables: 1  c: 0  Queries per secon

mysql连接:ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

自己电脑远程连接后,centos服务器mysql连接 不上.报错: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) 解决方法之一: 将连接参数“host”的值由“localhost”改成“127.0.0.1”: 来源:https://www.cnblogs.com/Lam7/p/6090989.html mysql连接:ERROR 2002

解决MySQL报错ERROR 2002 (HY000)

今天在为新的业务线搭架数据库后,在启动的时候报错 [email protected]:/usr/local/mysql/bin# ./mysql ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) 在此记录一下,希望能够给遇到此问题的兄弟们提供一个解决问题的思路,有了思路后一步一步排查问题就比较容易了,但是我这个问题比较奇怪,如果有了解的兄

IT忍者神龟之mysql远程连接:ERROR 1130 (HY000): Host '*.*.*.*' is not allowed to connect to this MySQL server解决

安装完MySQL后,远程连接数据库的时候,出现 ERROR 1130 (HY000): Host '192.168.0.1' is not allowed to connect to this MySQL server提示信息,不能远程连接数据库.考虑可能是因为系统数据库mysql中user表中的host是localhost的原因,于是,我尝试把这个值改为自己服务器的ip,果然就好用了,不过用 mysql -u root -p命令就连不上数据库了,需要用mysql -h 服务器ip -u roo

mac 安装mysql 报错“ERROR 2002 (HY000): Can not connect to local MySQL server through socket '/tmp/mysql.sock' (2)” 解决办法

首先安装 homebrew 再 brew install mysql 之后连接 mysql 无论是登录还是修改初始密码都会报如下的错误 ERROR 2002 (HY000): Can not connect to local MySQL server through socket '/tmp/mysql.sock' (2) 运行如下解决:参考 http://www.thinksaas.cn/group/topic/347978/ unset TMPDIR mysql_install_db --v

MySQL远程连接出现ERROR 2003 (HY000):Can't connect to MySQL server on'XXXXX'的问题

MySQL远程连接ERROR 2003 (HY000):Can't connect to MySQL server on'XXXXX'的问题 问题描述: 从一台linux远程连接另一台linux上的MySQL, 出现ERROR 2003 (HY000): Can't connect to MySQL server on 'xxx.xxx.xxx.85'(111)错误. [[email protected] ~]$ mysql -hxxx.xxx.xxx.85 -uroot -p Enter pa

mysql出错ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)

其他的贴会教你 1.键盘上win+r 2.输入cmd 3.输入net  start mysql 但是还是没用 你可以试试 1.右击开始菜单 2.点击windows PowerShell(i) 3.输入net  start mysql 4.输入mysql -u**** -p***** 上面的****代表你的账号密码,-u账号,-p密码, 我的账号:root 密码:123456, 那我就输入mysql -uroot -p123456 mysql出错ERROR 2003 (HY000): Can't

mysql报错ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)

23:29:02/2017-05-03 现象描述:在Command Line Client可以登陆,但是在命令提示符cmd下登陆出错. 我最终的解决办法是: 我先去看了一下我的my.ini配置文件. 新版5.7的配置文件不是在安装目录,而是在programDat/mysql文件目录下 打开文件之后: 我在安装的时候修改了默认端口3306为8082, 在cmd登陆的时候仍然是默认端口登陆的,所以会报错.那么在登陆的 时候可以指定端口, -P一定要大写. mysql报错ERROR 2003 (HY0

MySQL错误:ERROR 1221 (HY000): Incorrect usage of DB GRANT and GLOBAL PRIVILEGES

MySQL错误:ERROR 1221 (HY000): Incorrect usage of DB GRANT and GLOBAL PRIVILEGES在执行MySQL复制的前奏时:为主服务器创建用户以便从服务器连接,出现该错误:GRANT REPLICATION SLAVE ON a_database.* to 'repl'@'domain.test' IDENTIFIED BY 'slavepass';之所以指定数据库我是希望能只复制这个数据库而忽略其他(已创建的或今后会创建的)数据库.因