Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysqli too many connections (HY000/1040) and (08004/1040) is there a difference?

Tags:

php

mysql

mysqli

I'm getting the following errors in my script:

mysqli_connect(): (08004/1040): Too many connections 
mysqli_connect(): (HY000/1040): Too many connections

What is the difference and how can I solve this problem?

like image 804
ahmadMarafa Avatar asked Jan 18 '14 10:01

ahmadMarafa


1 Answers

Steps to resolve that issue:

  1. Check MySQL connection limit in configuration file or my.cnf
  2. Run below command to check:

    mysql -e "show variables like '%connection%';"
    
  3. You will see like this:

    max_connections = 500
    
  4. Increase it as per you want:

    max_connections = 50000
    
  5. Restart the MySQL service:

    $ service MySQL restart
    

Now check your website, I hope the error will not occur!

Thank You!

like image 116
Everdata technologies Avatar answered Nov 15 '22 14:11

Everdata technologies