CDbException CDbConnection failed to open the DB connection.

Ron

Member
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
 

twisted1919

Administrator
Staff member
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.
 

twisted1919

Administrator
Staff member
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.
 

Ron

Member
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 :(
 

twisted1919

Administrator
Staff member
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.
 

Ron

Member
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?
 

twisted1919

Administrator
Staff member
@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.
 

Ron

Member
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..
 

Ron

Member
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.
 

twisted1919

Administrator
Staff member
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.
 
  • Like
Reactions: Ron

Ron

Member
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..
 
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?
 
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
 
Top