Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

Find and Fix Magento Database Problems

This guide shows simple checks to find out why Magento cannot talk to its MySQL database.

Online Stores2 min read8 steps

What is MySQL?

MySQL is a database program. A database is like a big filing cabinet. Magento keeps products, customers and orders in it. If Magento cannot reach the cabinet, your store shows errors or a blank page.

Common messages are "Error establishing a database connection", "SQLSTATE" errors and "Too many connections".

Warning: Always export a backup of your database in phpMyAdmin before you change or repair anything.

Steps

  1. Read the error log first. In File Manager, open the var/log folder in your Magento folder. In Magento 2, also look in var/report. The newest files often name the problem.
  2. Check the database details Magento uses. In Magento 2 open app/etc/env.php. In Magento 1 open app/etc/local.xml. Look at the host, database name, username and password.
  3. Compare them with your database in the control panel. Open MySQL Databases. Check the names are spelled exactly the same. Many hosts add a prefix to the name.
  4. Check the database user is added to the database with all privileges. In MySQL Databases there is a section to add a user to a database.
  5. Open phpMyAdmin and click your database. If the tables are there, the database is healthy. If it is empty, restore your backup.
  6. If a table is marked "in use" or broken, select it in phpMyAdmin. In the drop-down at the bottom choose Repair table.
  7. Clear the Magento cache by deleting what is inside var/cache and, in Magento 2, var/page_cache.
  8. Reload the store.

Other causes

  • Too many connections: too many visitors, or a busy script, use all the database slots. Wait a few minutes. If it repeats, ask Hostvento support.
  • Wrong password after a change: if you changed the database password, update it in the Magento config file too.
  • Server problem: the MySQL service may be down. Hostvento support can check this for you.
Tip: When you contact support, copy the exact error text from var/log. It helps them help you faster. Use the support ticket page.

Quick recap

  • Back up the database first.
  • Read the logs in var/log.
  • Check the database name, user and password in the Magento config file.
  • Repair broken tables in phpMyAdmin.
  • Clear the cache and ask support if the problem stays.