• Hello,

    I suddenly started getting an ‘Error establishing a database connection’ error on 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 ‘w8WI11****’@’localhost’ (using password: YES) in /home/mydomain.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/mydomain.com/public_html/wp-load.php’ ) …/repair.php:10
    3 0.0015 373400 require_once( ‘/home/mydomain.com/public_html/wp-config.php’ ) …/wp-load.php:37
    4 0.0025 374800 require_once( ‘/home/mydomain.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 ‘w8WI11****’@’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 (w8WI11****) there’s an option to change a password at the following URL: https://mydomain.com:8090/phpmyadmin/server_privileges.php?username=w8WI11****&hostname=<myIP&gt;.

    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.

    • This topic was modified 3 years, 11 months ago by bcworkz. Reason: obfuscate DB user name

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter excelsiormerchant

    (@excelsiormerchant)

    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 ‘w8WI11****’@’localhost’ (using password: NO) in /home/mydomain.com/public_html/wp-includes/wp-db.php on line 1653

    • This reply was modified 3 years, 11 months ago by bcworkz.
    Bunty

    (@bhargavbhandari90)

    Not sure why this is happening. Everything seems OK to me. One more thing you can try creating a new user and a new password.

    Moderator bcworkz

    (@bcworkz)

    I’m getting the DB error message when I just checked now. If it was working for Bunty 11 hours ago, it’s an intermittent problem that’s probably beyond your ability to correct, you’ll need to bring in your host’s tech support for help.

    If the user name you posted was your actual DB user name (I obfuscated it just in case), I recommend creating a new user like Bunty suggests, then removing the user whose name was published here. While technically speaking, exposing the user name is not a security risk, assuming you use good strong passwords, it’s better the entire world doesn’t know of it all the same. Even though it’s no longer available here, it had been exposed to the world for over half a day.

    If assigning a new user does not help with connecting, you’ll need your host to help you resolve the issue, even if it’s a persistent problem and not intermittent.

    Thread Starter excelsiormerchant

    (@excelsiormerchant)

    It is not an intermittent issue, it’s not been working for over 15 hours and it didn’t work for Bunty either.

    New user and/or new password doesn’t work, I tried it. Plus under CyberPanel all that infrastructure happens behind the scene anyway, so that suggestion is not viable, it means everything needs to be recreated from scratch.

    The host is not in willing nor able to help with this as this is an application issue for them. Neither is CyberPanel, unfortunately.

    Bunty

    (@bhargavbhandari90)

    You can try Reset permission OR Grant Permissions to the user in MySQL.

    Maybe this helps
    https://www.digitalocean.com/community/tutorials/how-to-create-a-new-user-and-grant-permissions-in-mysql

    Thread Starter excelsiormerchant

    (@excelsiormerchant)

    Hi Bunty,

    I know I could.

    But the reason I’m cautious about messing with users any further (without some guidance from CyberPanel community, hopefully) is because CyberPanel creates several DBs, the user, and the password when one creates an ‘application’ (in CP’s terminology) in it, and by browsing through their code I can see that it’s a Django app with a bunch of internal DBs, for example it has a separate DB (named mysql) in which all the users are stored, separately from the WordPress-related DB (called by CyberPanel process identically as the corresponding user). It can be viewed at https://mydomain.com:8090/phpmyadmin/sql.php?server=1&db=mysql&table=user&pos=0 There’s an encrypted password in that table too. I’m just unsure where else the rest of the different pieces may be located.

    I also attempted to access the WordPress DBs directly from php script, with the similar result which means that WP access is being blocked (by CyberPanel) whereas phpAdmin seems to be able to manipulate the internal DBs (though w/o luck) which confirms my hunch that there is some missing link somewhere else preventing normal functioning of the site.

    I posted more details here https://stackoverflow.com/questions/65317075/error-establishing-database-connection-on-wordpress-site-in-cyberpanel (as SO is much better at allowing users to edit questions and use images/attachments) as well as at CyberPanel forum (which is normally unresponsive)

    Thanks.

    There are 4 major reasons for showing error establishing a database connection. See how to fix error establishing a database connection in WordPress. I hope it will work.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Error establishing a database connection’ is closed to new replies.