How to Solve "Error Establishing a Database Connection" on Websites?
What you see when you try to open your website "Error Establishing a Database Connection" The (Error Establishing a Database Connection) warning indicates that your site's source codes (PHP) and your MySQL/MariaDB database cannot talk to each other. This error is usually caused by incorrect password changes, database corruption, or server-side optimization issues. You can follow the steps below to solve the problem.
Step 1: Check wp-config.php or Database Settings File
80% of the reason for the error is that the database information is written incorrectly in the settings file:
- Where your site is installed via cPanel, Plesk or FTP
public_htmlGo to the main directory. - If you are using WordPress
wp-config.phpOpen the file (config.php, database.php, etc. in special software) in edit mode. - Find the following lines and check whether they match exactly the current information you created on cPanel/Plesk:
define('DB_NAME', 'veritabanı_adınız');define('DB_USER', 'veritabanı_kullanıcı_adınız');define('DB_PASSWORD', 'veritabanı_şifreniz');define('DB_HOST', 'localhost');*(Note: If you are not using a remote SQL server, this value must remain 'localhost').*
Step 2: Verify MySQL User Permissions and Privileges
Even if the database name and password are correct, the user may not have been assigned full privileges to the database:
- Log in to cPanel and MySQL® Databases Enter the (MySQL Databases) page.
- Scroll to the bottom of the page and select the relevant user and database from the "Add User To Database" section. Add say.
- On the screen that opens "ALL PRIVILEGES" Save the changes by checking the (All Privileges) box.
Step 3: Repair Corrupt Tables (Repair Database)
Sudden server shutdown or SQL crashes may have corrupted the tables. To repair tables from cPanelphpMyAdminpanel, select your database from the left menu, mark all tables and click on the drop-down menu at the bottom. "Mend the Paintings" Click (Repair Table).
This article is specially prepared for PvPServer.