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
- Read the error log first. In File Manager, open the
var/logfolder in your Magento folder. In Magento 2, also look invar/report. The newest files often name the problem. - Check the database details Magento uses. In Magento 2 open
app/etc/env.php. In Magento 1 openapp/etc/local.xml. Look at the host, database name, username and password. - 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.
- 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.
- Open phpMyAdmin and click your database. If the tables are there, the database is healthy. If it is empty, restore your backup.
- If a table is marked "in use" or broken, select it in phpMyAdmin. In the drop-down at the bottom choose Repair table.
- Clear the Magento cache by deleting what is inside
var/cacheand, in Magento 2,var/page_cache. - 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.