Why do you get this error?
You are getting this error because WordPress is not able to connect with database. There can be multiple reasons for it. Following below steps will solve it for 95% times. For other please feel free to brain storm with us.
1. DB credentials are incorrect
Check database credentials in wp-config.php. Check for typo error.
2. Database table is corrupt
If you are getting this error on front page, you must check the backend (www.yoursite.com/wp-admin). In most cases, it is a corrupt db problem. Add a line in wp-config
Now again access backend (www.yoursite.com/wp-admin). Select repair Database
If you get the result as certain table cannot be repaired. You should visit phpMyAdmin in cpanel and repair particular table from operation tab.