Fix 'Database Errors' in Google Search Results
Database errors in Google SERPs mean the site's database connection failed. Here's how to fix it fast, with the actual cause explained.
Quick Answer
Clear your site cache, restart the database server, check wp-config.php or config.php credentials, and repair the database tables using mysqlcheck or phpMyAdmin.
What's Actually Happening Here
When Google crawls your site and hits a page that can't connect to the database, it indexes that error. Then anyone searching sees your URL with a "database error" snippet. The cause is almost always the database server being down, credentials being wrong, or corrupted tables. I've seen this most often on shared hosting when MySQL max connections get hit during a traffic spike, or after a PHP update that breaks the database driver. The Google search results page itself isn't broken — it's showing your site's error because the crawler saw it.
Fix Steps (in Order, No Skipping)
- Check if the database server is running. SSH into your server and run
systemctl status mysqlorservice mysqld status. If it's dead, start it:systemctl start mysql. On shared hosting, check your control panel — if MySQL is stopped, restart it there. This accounts for about 60% of cases. - Verify the database credentials. Open your config file — for WordPress it's
wp-config.php, for Laravel it's.env. Double-check the DB_NAME, DB_USER, DB_PASSWORD, and DB_HOST. If you recently changed the database password but forgot to update the config, you'll get this error. The DB_HOST is oftenlocalhost, but some hosts use a socket path — if you seelocalhost:/tmp/mysql.sockand MySQL moved to a different socket, change it to127.0.0.1. - Repair the database tables. Run
mysqlcheck -u root -p --auto-repair --all-databasesfrom the command line. This scans and fixes corrupted tables. In phpMyAdmin, select the database, check "Check All", then from the dropdown choose "Repair table". This handles cases where a crash left tables in a bad state. - Clear site and database caches. Flush your application cache — for WordPress, that means the object cache in wp-content/cache. Also clear the MySQL query cache with
RESET QUERY CACHE;in phpMyAdmin. Sometimes a stale cache just reconnects to the same broken state. - Increase max connections. If you're on a VPS or dedicated server, edit
/etc/mysql/my.cnfor/etc/my.cnfand setmax_connections = 500(or higher). Then restart MySQL. On shared hosting, you can't change this yourself — you'll need to ask the host to bump it or upgrade your plan.
If the Main Fix Fails
Sometimes the database is fine but the PHP module that connects to it is broken. Check your PHP error log at /var/log/php_errors.log. If you see errors about missing MySQL extensions, reinstall the PHP MySQL module. On Ubuntu/Debian: sudo apt install php-mysql. On CentOS: sudo yum install php-mysqli. Restart Apache or PHP-FPM after.
Another edge case: if your site runs on WordPress and the error only shows on some pages, a plugin might be crashing the database connection. Disable all plugins via wp-admin (or rename the plugins folder via FTP to plugins_off). If the error goes away, enable them one by one until you find the culprit. I've seen caching plugins and security plugins do this.
Prevention for Next Time
Set up monitoring. Use a free tool like UptimeRobot or a cron job that checks if your site returns HTTP 200. If it ever returns a database error page, you'll get an alert within minutes — before Google crawls it. Also, schedule nightly database repairs with this cron job: 0 3 * * * mysqlcheck -u root -pYourPassword --auto-repair --all-databases. And always back up your database before any major update — mysqldump -u root -p yourdb > backup.sql. The real fix is catching the problem before Google does.
Was this solution helpful?