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.
Related
( ! ) Warning: mysqli_connect(): (HY000/1045): Access denied for user 'root'#'localhost' (using password: YES) in C:\wamp64\www\web\db.php on line 3
Call Stack
# Time Memory Function Location
1 0.0840 407896 {main}( ) ...\registration.php:0
2 0.0850 408192 require( 'C:\wamp64\www\web\db.php' ) ...\registration.php:73
3 0.0850 408192 mysqli_connect ( ) ...\db.php:3
Failed to connect to MySQL: Access denied for user 'root'#'localhost' (using password: YES)
Everything look ok, but still getting problem in connection with phpmyadmin.
It seems like you're using WAMP. WAMP's default user is root and the password is blank (unless you had changed it). You're connecting to MySQL with a password (see using password: YES), it needs to be using password: NO; meaning logging in with a blank ('') password. In \db.php:3 rewrite the MySQL password for mysqli_connect with '' and try again.
Software:
PHP 7.3
MySQL Workbench 8.0
This is my PHP code:
try {
$link = mysqli_connect($DB_SERVER,$DB_USERNAME, $DB_PASSWORD,$DB_NAME,3306);
} catch (Exception $e){
throw new Exception("Can't execute command. ERROR: ".$e);
}
This is the error:
Warning: mysqli_connect(): PHP was built without openssl extension, can't send password encrypted in login.php on line 11
Warning: mysqli_connect(): (HY000/1045): Access denied for user 'XXXXX_admin'#'localhost' (using password: YES) in C:\inetpub\wwwroot\ on line 11
PHP Warning: mysqli_error() expects parameter 1 to be mysqli, boolean given in C:\inetpub\wwwroot\ on line 24
PHP Fatal error: Uncaught Exception: ERROR: Failed to connect to in C:\inetpub\wwwroot:24 Stack trace: #0 {main} thrown in C:\inetpub\wwwroot\ on line 24
Now the magic, when I login in to mysql workbench with the same user and password everything works fine. I have access to tables and other things. When I login in with my PHP application everything works also.
So my problem is everytime my server reboots I have to login in with MySQL Workbench, to get it working again. What am I missing?
You need to do verify few of the steps:
All necessary extensions are enabled like mysqli, openssl etc
Port is available
MySQLi is connecting at 3306 Port
Rest could be your username and password issue
Let us know once you will be verifying all above steps.
What you need to do is enable the openssl extension for php.
Open your php.ini file and search for the line:
;extension=php_openssl.dll
You need to uncomment it by removing the semicolon in front of it, leaving you with this:
extension=php_openssl.dll
i cannot install opencart on third step.i have the following problem:
Warning: mysqli::mysqli(): (HY000/1045): Access denied for user
'root'#'localhost' (using password: NO) in
C:\wamp\www\opencart\upload\system\library\db\mysqli.php on line
7Warning: DB\MySQLi::__construct(): Couldn't fetch mysqli in
C:\wamp\www\opencart\upload\system\library\db\mysqli.php on line
10Warning: DB\MySQLi::__construct(): Couldn't fetch mysqli in
C:\wamp\www\opencart\upload\system\library\db\mysqli.php on line
10Notice: Undefined variable: mysql in
C:\wamp\www\opencart\upload\install\controller\install\step_3.php on
line 280Notice: Trying to get property of non-object in
C:\wamp\www\opencart\upload\install\controller\install\step_3.php on
line 280
php× 1144494
If someone is getting same type of error ,you could try out this,
username=admin
password=
keep your password null
The reason this might happened is because of password you gave in phpmyadmin during setting time.
I've upgraded from a 6 year old Xampp to the next latest one:
xampp-win32-7.0.23-0-VC14-installer.exe
Before install I did a Mysql Dump All:
mysqldump -u root -p --all-databases > all-db-dump.sql
After install I Imported that all-db-dump.sql from phpMyAdmin.
When starting my PHP-application filmtv.php I get the above errors, see attached filmtv.php.png.
Look at the source samples and I hope someone out there have an idea of whats wrong, cause I expected it to work smoothly without having to change my application.
Also, if I do a minor change using phpMyAdmin like adding a new user then I cannot use phpMyAdmin anymore it'll respond that user/pwd is incorrect, very strange. Up to now I've done 5 re-installs because of that.
From phpMyAdmin user:
root localhost Yes ALL PRIVILEGES
filmtv.php
Warning: mysqli_connect(): (HY000/1045): Access denied for user 'root'#'localhost' (using password: YES) in C:\xampp\htdocs\css\bertil.php on line 2
Warning: mysqli_connect(): (HY000/1045): Access denied for user 'root'#'localhost' (using password: YES) in C:\xampp\htdocs\css\bertil.php on line 3
Fatal error: Uncaught Error: Call to undefined function mysql_error() in C:\xampp\htdocs\filmtv.php:156 Stack trace: #0 {main} thrown in C:\xampp\htdocs\filmtv.php on line 156
filmtv.php includes
include 'css/adam.php';
include 'css/bertil.php';
if (!$cxn) { echo "Unable to connect to DB: " . mysql_error();
exit;}
Source-code:
*adam.php:*
<?php
$user="root";
$host="localhost";
$password="tenthirty";
$database = "ljung";
?
*bertil.php:*
<?php
$cxn = mysqli_connect($host,$user,$password,$database);
$cxu = mysqli_connect($host,$user,$password,$database);
?>
_By the way, my Xampp install is:
Includes: Apache 2.4.27, MariaDB 10.1.26, PHP 7.0.23, phpMyAdmin 4.7.4, OpenSSL 1.0.2, XAMPP Control Panel 3.2.2, Webalizer 2.23-04, Mercury Mail Transport System 4.63, FileZilla FTP Server 0.9.41, Tomcat 7.0.56 (with mod_proxy_ajp as connector), Strawberry Perl 7.0.56 Portable_
_
Cheers,
Torbjorn
Stockholm
In the newest version of Xampp they start to use mariadb instead of mysql
so you can't log in as root user so you have to create new user and grant your privileges in that user
I tried to move a database from XAMPP to my Synology NAS.
Now I get this error:
Warning: mysqli_connect(): (HY000/1045): Access denied for user 'qs'#'localhost' (using password: YES) in /volume1/web/db.php on line 3
In the Database i created a User:
Name: qs
password: test
host: %
privileges: all..
in php i use:
$link=mysqli_connect("localhost","qs","test","qs",3306);
localhost because the Synology is the localhost of the web-page. i also tried to change to:
$link=mysqli_connect("10.0.0.99","qs","test","qs",3306);
then it says:
Warning: mysqli_connect(): (HY000/1045): Access denied for user 'qs'#'JF_SYN' (using password: YES) in /volume1/web/db.php on line 3
"JF_SYN" is the name of my Synology
i also tried to set the host of the database user, to that specific IP, but that doesn't change anything.
Database connection is working with this user and the password, i tried with HeidSQL,MSYQL-Workbench and Oracle SQL Developer, all those tools can make a connection.
I had the same issue, with my Synology NAS
Use MyAdmin and remove the “ANY” or “Anonymous” user accounts.
This should Fix your issue.