I suddenly started getting an 'Error establishing a database connection'
on the load of my WooCommerce site which is hosted on CyberPanel under Centos 8.
To understand what's going on, I've put the following in wp_config.php:
define('WP_ALLOW_REPAIR', true);
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true);
That uncovered the following stack trace:
( ! ) Warning: mysqli_real_connect(): (HY000/1045): Access denied for user 'w8WI11xxxxGCO'@'localhost' (using password: YES) in /home/example.com/public_html/wp-includes/wp-db.php on line 1653
Call Stack
# Time Memory Function Location
1 0.0009 372512 {main}( ) .../repair.php:0
2 0.0012 373000 require_once( '/home/example.com/public_html/wp-load.php' ) .../repair.php:10
3 0.0015 373400 require_once( '/home/example.com/public_html/wp-config.php' ) .../wp-load.php:37
4 0.0025 374800 require_once( '/home/example.com/public_html/wp-settings.php' ) .../wp-config.php:84
5 0.0546 832240 require_wp_db( ) .../wp-settings.php:124
6 0.0610 836424 wpdb->__construct( ) .../load.php:527
7 0.0610 836424 wpdb->db_connect( ) .../wp-db.php:632
8 0.0611 838000 mysqli_real_connect ( ) .../wp-db.php:1653
Access denied for user 'w8WI11xxxxxGCO'@'localhost' (using password: YES)
Error establishing a database connection
I seem to be able to access the DB via the phpMyAdmin UI through CyberPanel and there I can see that in the DB that seems to be associated with my WordPress app (w8WI11xxxxGCO) there's an option to change a password at the following URL: https://example.com:8090/phpmyadmin/server_privileges.php?username=w8WI11xxxxGCO&hostname=<myIP>
.
I attempted to change the password to the one in the wp_config.php
.
After rebooting Lightspeed server and retry, the erroneous behavior still persists.
How can I recover from this?
Why wouldn't the application start while the DB is perfectly accessible via phpMyAdmin?
I'd appreciate if anyone could guide me at fixing this issue.
Thank you in advance.
P.S. I also tried configuring this user to have no password and granting him all privileges, but that doesn't change the situation either, except for the error message now reading as:
Warning: mysqli_real_connect(): (HY000/1045): Access denied for user 'w8WI11xxxxxGCO'@'localhost' (using password: NO) in /home/example.com/public_html/wp-includes/wp-db.php on line 1653
I've then decided to run the following script from the command line against the DB:
which confirmed that something in CyberPanel messed up the credentials somehow:
PHP Warning: mysqli_connect(): (HY000/1045): Access denied for user 'w8WI11xxxxxGCO'@'localhost' (using password: YES) in /home/example
.com/public_html/testConnection.php on line 2
PHP Stack trace:
PHP 1. {main}() /home/example.com/public_html/testConnection.php:0
PHP 2. mysqli_connect() /home/example.com/public_html/testConnection.php:2
PHP Warning: mysqli_error() expects exactly 1 parameter, 0 given in /home/example.com/public_html/testConnection.php on line 4
PHP Stack trace:
PHP 1. {main}() /home/example.com/public_html/testConnection.php:0
PHP 2. mysqli_error() /home/example.com/public_html/testConnection.php:4
Could not connect: [root@example ~]#
I would be very curious to find what in CyberPanel messes up the configuration in such a way that corrupts the DB credentials and doesn't allow them to be restored.
Perhaps someone (hopefully representing the CyberPanel team or having enough knowledge of it) could shed some light on their product for me here.