I have faced this issue in wordpress, Just follow the below steps to fix
Add this code in wp-config.php
Click repair and optimize button to repair your database.
Make sure you remove this line of code after you have fixed your
database connection error message.
If you still have this issues, contact your hosting provider. They will
fix this easily.