If you face Error establishing a database connection in your wordpress site make sure that you use correct database name, user name and password in wp-config.php file.
You can repair wordpress easily. Use the below code in wp-config.php
define('WP_ALLOW_REPAIR', true);
For check manually database connection, create a file in public_html and paste the code inside php:
$link = mysqli_connect('localhost', 'your_db_username', 'your_db_password');
if (!$link) {
die('Could not connect: ' . mysqli_error());
}
echo 'Connected successfully';
mysqli_close($link);
On the other hand you can update site url from phpmyadmin:
UPDATE wp_options SET option_value='YOUR_SITE_URL' WHERE option_name='siteurl'
Subscribe my channel and press the bell icon for get update first. Thanks
6 сен 2024