DEV Community

Samcorp
Samcorp

Posted on

Database Connection Error in WordPress

Description
The website shows "Error Establishing a Database Connection."

Causes
Incorrect database credentials in wp-config.php.
Corrupted database.
Database server is down.

Solution

  • Verify Database Credentials: Check the wp-config.php file for the correct:
define('DB_NAME', 'your_database_name');
define('DB_USER', 'your_username');
define('DB_PASSWORD', 'your_password');
define('DB_HOST', 'localhost');
Enter fullscreen mode Exit fullscreen mode
  • Repair the Database: Add the following to wp-config.php and visit yourwebsite.com/wp-admin/maint/repair.php:
define('WP_ALLOW_REPAIR', true);

Enter fullscreen mode Exit fullscreen mode
  • Check Server Status: Ensure the database server is running.

WordPress development services to build custom websites that are fast, secure, and easy to manage. From creating themes and plugins to optimizing performance, we ensure your website meets your business needs. Get a professional, user-friendly site that stands out.

Top comments (0)