WordPress | Error establishing a database

Viewed 9

I'm a beginner at WordPress and coding/programming.

So here's the issue, my website is getting this error: Error establishing a database connection.

and the whole page was like this -

Warning: mysqli_real_connect(): (HY000/2002): No such file or directory in /var/www/wordpress/wp-includes/wp-db.php on line 1753

No such file or directory

Error establishing a database connection This either means that the username and password information in your wp-config.php file is incorrect or that contact with the database server at localhost could not be established. This could mean your host’s database server is down.

Are you sure you have the correct username and password? Are you sure you have typed the correct hostname? Are you sure the database server is running? If you are unsure what these terms mean you should probably contact your host. If you still need help you can always visit the WordPress Support Forums.

line 1752 - 1757 of wp-db.php file is here -

if ( WP_DEBUG ) {
                            mysqli_real_connect( $this->dbh, $host, $this->dbuser, $this->dbpassword, null, $port, $socket, $client_flags );
                    } else {
                            // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
                            @mysqli_real_connect( $this->dbh, $host, $this->dbuser, $this->dbpassword, null, $port, $socket, $client_flags );
                    }

my wp-config.php file (I tried changing this as the database above) -

// ** Database settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'dbh' );

/** Database username */
define( 'DB_USER', 'dbuser' );

/** Database password */
define( 'DB_PASSWORD', 'dbpassword' );

/** Database hostname */
define( 'DB_HOST', 'localhost' );

can someone tell me what's the error, and how can I fix it?

0 Answers
Related