WordPress keeps showing ‘Error Establishing a Database Connection

Solution:
This issue can have several causes. Since the problem is not permanent, it’s likely related to a network or MySQL issue.

To fix it, try repairing the database by following Step 3 from the tutorial:

1. dd the following line to your wp-config.php file:

define('WP_ALLOW_REPAIR', true);

2. Visit: http://www.yoursite.com/wp-admin/maint/repair.php

3. Follow the on-screen instructions as outlined in the tutorial.