Tag: Amazon Aurora

  • Amazon RDS ERROR 1040 (08004): Too many connections

    On an Amazon RDS Aurora data base, when i connect, i get error

    root@ip-10-0-0-234:/var/www/html# mysql -h sok.cb21y0qmezhd.us-west-2.rds.amazonaws.com -u sok_wp -p0ZEkrkQx  sok_wp
    ERROR 1040 (08004): Too many connections
    root@ip-10-0-0-234:/var/www/html# 
    

    This error is due to max_connections setting in MySQL exceeded. By default Amazon RDS set max_connections based on size of RDS instance using following formula.

    GREATEST({log(DBInstanceClassMemory/805306368)*45},{log(DBInstanceClassMemory/8187281408)*1000})
    

    To see current value, run

    MySQL [sok_wp]> show variables like 'max_connections';
    +-----------------+-------+
    | Variable_name   | Value |
    +-----------------+-------+
    | max_connections | 90    |
    +-----------------+-------+
    1 row in set (0.00 sec)
    
    MySQL [sok_wp]> 
    

    To change default value, you need to create a “Parameter group” under Amazon RDS > Parameter groups

    On next page, select “Parameter group family” based on what ever RDS version you are using. In this cause i use Amazon Aurora database, so i select “aurora5.6”

    Group name and Description, use any value you like, it is just for identification purpose only.

    Once created, it will list all available parameter groups. click on newly created parameter group, on next page, it show all options. In the top search box, type in “max_connections” to find the settings. Edit and save.

    Now we need to associate this newly created parameter group with Amazon RDS instance, for this go to Amazon RDS > Instances

    Select the instance you need to edit, then from “Instance Actions” drop down menu, select modify.

    On next page page, you have the option to select “DB parameter group”, select the newly created parameter group.

    On next page, you have option to apply change immediately or apply during maintenance window.

    You need to reboot the instance to apply the changes.