If your WordPress site displays the error "Error Connecting to the Database" and is out of sync with your database, you need to update the database connection strings. It is a fatal mistake that prevents users from accessing your WordPress website.
It is among the most typical WordPress mistakes. In addition to using invalid credentials, this error may also occur if the database server is offline or if the database files are damaged.
WordPress requires the below information for connecting to the database:
Database name
Database Username
Database password
Database server
wp-config.php files store this information.
How to Update Database Connection Strings?
Step 1: Log into your CPanel.
Step 2: Scroll down to the Files and choose File Manager.
Step 3: Inside the public_html directory, search for the wp-config.php file.
Step 4: Right-click on the wp-config file and select Edit.
Step 5: Find the following code in your wp-config.php file.
define( 'DB_NAME', 'Database_name' );
/** Database username */
define( 'DB_USER', 'Database_username' );
/** Database password */
define( 'DB_PASSWORD', 'Database_password’ );
/** Database hostname */
define( 'DB_HOST', 'Database_hostname’ );
Step 6: Confirm the above information with your database.
Step 7: Click on Save to save changes.
That's all.