To import a database or table with phpMyAdmin, open the database or table, go to the Import tab, choose your saved .sql file and click Go. This guide covers the steps and the most common import errors.
phpMyAdmin is a web-based tool for managing MySQL and MariaDB databases. You can import a file you exported earlier, for example to restore a table that has become corrupt. To export a copy first, see our guide on exporting databases and tables with phpMyAdmin.
Before you start
You will need:
- Your database name and database user login. Find these in the client area at https://my.hostking.host or in your welcome email.
- A saved export file, usually a .sql file. A .gz or .zip compressed version also works.
If you want to replace a table that has become corrupt, delete the old table first. Make sure you have a copy of it before you delete it.
Import a database or table
cPanel
- Log in to the cPanel control panel.
- Open phpMyAdmin from the Databases section.
- In the left panel, click the database. To import into one table, click the table instead.
- Click the Import tab at the top of the page.
- Under File to import, click Choose File and select your file on your computer.
- Scroll down and click Go.
- Wait for the confirmation message at the top of the page.
DirectAdmin
- Log in to DirectAdmin.
- Go to MySQL Management.
- Click the phpMyAdmin icon next to your database.
- Log in with your database user name and password if prompted.
- In the left panel, click the database. To import into one table, click the table instead.
- Click the Import tab at the top of the page.
- Under File to import, click Choose File and select your file on your computer.
- Scroll down and click Go.
- Wait for the confirmation message at the top of the page.
You can also drag and drop a file from your file manager onto the phpMyAdmin window. This works on the Import tab.
Troubleshooting
The file is too large
phpMyAdmin shows the maximum upload size on the Import tab. Check this limit before you start. If your file is larger:
- Compress the .sql file to .sql.gz or .zip and import the compressed file.
- Import the file over SSH instead (see below).
The import times out
Large imports can stop before they finish. Try compressing the file or importing it over SSH.
Access denied (error 1044)
The database user does not have permission to use this database. Check the user is assigned to the database in MySQL Management in DirectAdmin, or contact support if you are unsure.
The file contains CREATE DATABASE or DROP DATABASE
The hosting environment may block these statements. Remove them from the file, so it only contains table statements, and import into your existing database.
SQL syntax errors
Check the file for missing semicolons or commands your MySQL version does not support. If the file came from an older server, re-export it from the source.
Import over SSH for large files
For large files, you can import from the command line. Upload the file with SFTP or the file manager first, then run this command over SSH:
mysql -u USERNAME -p DATABASE_NAME < /path/to/file.sql
Replace USERNAME and DATABASE_NAME with the values from your client area or welcome email. Check that SSH access is included in your plan before you use this method.
Need help?
If an import still fails, contact support using live chat on the website or a support ticket from the client area at https://my.hostking.host.
