1. CodersEden Marketplace for designers and developers

CDbException CDbConnection failed to open the DB connection.

Discussion in 'General discussions' started by Ron, Sep 23, 2015.

  1. Ron

    Ron Member

    Joined:
    Aug 18, 2015
    Messages:
    51
    Likes Received:
    0
    S.E:
    Expired
    L.T:
    Regular
    L.C:
    1
    Getting this error for both Admin and the Customers and can't seem to login to check error logs

    Other applications with mysql connectivity are working fine so no problems with MYSQL being down and error logs shows nothing on cpanel
     
  2. twisted1919

    twisted1919 Administrator Staff Member

    Joined:
    Dec 27, 2014
    Messages:
    10,659
    Likes Received:
    2,472
    Well this error says mailwizz cannot connect to the database, maybe your mailwizz credentials for db have changed?
    The database info is stored in apps/common/config/main-custom.php in case you need to adjust it.
     
  3. Ron

    Ron Member

    Joined:
    Aug 18, 2015
    Messages:
    51
    Likes Received:
    0
    S.E:
    Expired
    L.T:
    Regular
    L.C:
    1
    Nope the credentials are all fine.. still giving error...
     
  4. twisted1919

    twisted1919 Administrator Staff Member

    Joined:
    Dec 27, 2014
    Messages:
    10,659
    Likes Received:
    2,472
    Another thing you might check is that some mysql settings will allow certain number of connections per mysql user, so maybe you have reached that number.
    Look into mysql log, the answer is there.
     
  5. Ron

    Ron Member

    Joined:
    Aug 18, 2015
    Messages:
    51
    Likes Received:
    0
    S.E:
    Expired
    L.T:
    Regular
    L.C:
    1
    We are on shared hosting as of now so can't check the mysql log but as I said earlier, we have other mysql applications for the same user and those apps are running fine..

    We have almost all the delivery servers configured , have few customers and campaigns confgured..please don't tell me that we would need to re-install the mailwizz app once again :(
     
  6. twisted1919

    twisted1919 Administrator Staff Member

    Joined:
    Dec 27, 2014
    Messages:
    10,659
    Likes Received:
    2,472
    Reinstalling mailwizz won't help you.
    Things are simple, the error is there because for some reason mailwizz can't connect to your database server, there's absolutely nothing mailwizz can do to help you go over this. Have your hosting look into the issue and see why it can't connect, i have my money on the mysq/server limitations.
     
  7. Ron

    Ron Member

    Joined:
    Aug 18, 2015
    Messages:
    51
    Likes Received:
    0
    S.E:
    Expired
    L.T:
    Regular
    L.C:
    1
    I am guessing the same about the mysql connectivity thing but our hosts support is a concern.. let me check...otherwise I would keep the current installation and make a new folder on the same domain and install a fresh piece..and then transfer the old db to the new one.. will that work?
     
  8. twisted1919

    twisted1919 Administrator Staff Member

    Joined:
    Dec 27, 2014
    Messages:
    10,659
    Likes Received:
    2,472
    @Ron - That trick aint going to work, remember, you're on same server so at some point you'll get into same issue again if your host does not fix it.
     
  9. Ron

    Ron Member

    Joined:
    Aug 18, 2015
    Messages:
    51
    Likes Received:
    0
    S.E:
    Expired
    L.T:
    Regular
    L.C:
    1
    I understand.. will check with hosts now..

    Can someone point me to a test php file for checking CDbConnection instead of connecting through mailwizz ..so that to check if it's the same hosts problem..
     
  10. twisted1919

    twisted1919 Administrator Staff Member

    Joined:
    Dec 27, 2014
    Messages:
    10,659
    Likes Received:
    2,472
  11. Ron

    Ron Member

    Joined:
    Aug 18, 2015
    Messages:
    51
    Likes Received:
    0
    S.E:
    Expired
    L.T:
    Regular
    L.C:
    1
    Changed to Debug mode.. Gives so many errors :(

    Screenshot attached
     
  12. twisted1919

    twisted1919 Administrator Staff Member

    Joined:
    Dec 27, 2014
    Messages:
    10,659
    Likes Received:
    2,472
  13. Ron

    Ron Member

    Joined:
    Aug 18, 2015
    Messages:
    51
    Likes Received:
    0
    S.E:
    Expired
    L.T:
    Regular
    L.C:
    1
  14. Ron

    Ron Member

    Joined:
    Aug 18, 2015
    Messages:
    51
    Likes Received:
    0
    S.E:
    Expired
    L.T:
    Regular
    L.C:
    1
    Response from Host

    2015-09-23 08:32:14 +0000 [info] killed_thread_id:14480054 user:goonet_list host:localhost db:goonet_list command:Sleep time:22 query:
    2015-09-23 08:59:40 +0000 [info] killed_thread_id:14492521 user:goonet_list host:localhost db:goonet_list command:Sleep time:22 query:
    ------
    ------

    The MySQL queries for the above mentioned databases are getting killed by the server which is causing the intermittent issue with the site loading. You can verify the same from cPanel >> Health checks and Monitoring >> Mysql Killed Queries.

    Please note that, the long_query_time set for the MySQL service is 15 seconds.

    Since it is a shared server, we can't alter this values for single domain. We have set this limit carefully to avoid any wastage/abuse of server resources and increasing the limit will result in degradation of server's performance.

    Hence, we strongly recommend to contact your developer and optimize the database queries and PHP scripts for the better performance of the site.
     
  15. twisted1919

    twisted1919 Administrator Staff Member

    Joined:
    Dec 27, 2014
    Messages:
    10,659
    Likes Received:
    2,472
    At least my hunch was right.
    They can strongly recommend what they want, if they give you limited resources, i can't do magic here.
    If your number of subscribers is very high and the shared hosting can cope with it, then go with a VPS.
     
    Ron likes this.
  16. Ron

    Ron Member

    Joined:
    Aug 18, 2015
    Messages:
    51
    Likes Received:
    0
    S.E:
    Expired
    L.T:
    Regular
    L.C:
    1
    I sorted this out doing google search..

    In the DB config file where you have mentioned to connect to localhost - I changed it to the server IP and it worked ... it was not connecting to the mentioned localhost mysql socket but the IP worked..

    Also, would request if you can remove the uploaded screenshot as it has the db and username details mentioned..for security purposes..
     
  17. twisted1919

    twisted1919 Administrator Staff Member

    Joined:
    Dec 27, 2014
    Messages:
    10,659
    Likes Received:
    2,472
    @Ron - Removed the screenshot ;)
     
    Ron likes this.
  18. carlos alvarez

    carlos alvarez Member

    Joined:
    Aug 30, 2016
    Messages:
    94
    Likes Received:
    17
    S.E:
    Expired
    L.T:
    Regular
    L.C:
    1
    Dear @twisted1919 & Ron

    I continually get the error: CDbException CDbConnection failed to open the DB connection. I am using MW v1.3.7.8

    My actual MySQL config file contains below data. I have optimized this file using: https://tools.percona.com/wizard

    ########################################################
    /etc/mysql/my.cnf

    [client]
    port=3306
    socket=/var/run/mysqld/mysqld.sock

    [mysqld_safe]
    socket=/var/run/mysqld/mysqld.sock

    [mysqld]
    user=mysql
    pid-file=/var/run/mysqld/mysqld.pid
    socket=/var/run/mysqld/mysqld.sock
    port=3306
    basedir=/usr
    datadir=/var/lib/mysql
    tmpdir=/tmp
    lc-messages-dir=/usr/share/mysql

    # LOGS #
    log_error=/var/log/mysql/error.log
    log-queries-not-using-indexes = 1
    slow-query-log = 1
    slow-query-log-file = /var/log/mysql/mysql-slow.log

    # BINARY LOGGING #
    log-bin = /var/lib/mysql/mysql-bin
    expire-logs-days = 14
    sync-binlog = 1

    symbolic-links=0

    skip-external-locking
    key_buffer_size = 64K
    max_allowed_packet = 1M
    table_open_cache = 12
    sort_buffer_size = 128K
    read_buffer_size = 512K
    read_rnd_buffer_size = 256K
    net_buffer_length = 2K
    thread_stack = 240K

    innodb_file_per_table = 1
    innodb_buffer_pool_size = 2G

    # Connections #
    max_connections=120
    max_user_connections=40
    wait_timeout=300
    interactive_timeout=60
    long_query_time=60

    # SAFETY #
    max-allowed-packet = 16M
    max-connect-errors = 1000000
    # skip-name-resolve
    sysdate-is-now = 1
    innodb = FORCE

    # CACHES AND LIMITS #
    tmp-table-size = 32M
    max-heap-table-size = 32M
    query-cache-type = 0
    query-cache-size = 0
    max-connections = 500
    thread-cache-size = 50
    open-files-limit = 65535
    table-definition-cache = 1024
    table-open-cache = 2048

    !includedir /etc/mysql/conf.d/
    ########################################################

    The MySQL log files shows no errors.

    What else can I do?
     
  19. twisted1919

    twisted1919 Administrator Staff Member

    Joined:
    Dec 27, 2014
    Messages:
    10,659
    Likes Received:
    2,472
  20. carlos alvarez

    carlos alvarez Member

    Joined:
    Aug 30, 2016
    Messages:
    94
    Likes Received:
    17
    S.E:
    Expired
    L.T:
    Regular
    L.C:
    1
    CDbException
    CDbConnection failed to open the DB connection: SQLSTATE[42000] [1203] User admin_mw1378 already has more than 'max_user_connections' active connections

    /home/admin/web/email-mark.cl/public_html/mw/1.3.7.8/apps/common/components/managers/OptionsManager.php(164)

    My my.cnf file has:

    max_user_connections = 100

    So, I changed this parameter to:

    max_user_connections = 1000

    and then restarted the MySQL (Percona) server

    Let me check now if the problem is solved or not ! Thanks
     

Share This Page