Solution 1:
The “Error establishing a database connection” usually means that your database credentials are incorrect. Check your:
- Database name
- Username
- Password
- Host
Refer to the WordPress Codex: Common WordPress Errors – Error Establishing Database Connection
Tips:
- Ensure localhost is the correct host. If you are using MAMP or WAMP, the host may differ.
- Use Adminer (http://www.adminer.org/
) to find your database credentials and manage the database. - If you have shell access, try:
mysql> SHOW DATABASES;
This lists all databases and helps verify the database name.
To get server and port information:
mysqlserverinfo --server=root:pass@localhost -d --format=vertical