How to import a database with phpMyAdmin
Restore or migrate a database by importing an SQL file with phpMyAdmin, and fix the errors imports commonly hit.
Before importing
- Create the database first in Account Manager › MySQL Management if it doesn’t exist. How to create a MySQL database in DirectAdmin
- Importing into a database that already has tables? Export it first as a safety copy. Tables with the same name are overwritten if the file contains
DROP TABLE, or cause “already exists” errors if not.
Steps
- Open Extra Features › phpMyAdmin.
- Select the target database in the left sidebar.
- Open Import.
- Choose your
.sqlor.sql.gzfile. - Leave the format as SQL and select Import.
A success message lists how many queries ran.
Common errors
| Error | Cause | Fix |
|---|---|---|
No database selected | Imported without selecting a database first | Select the database, then import |
#1044 Access denied ... to database 'oldname' | File contains CREATE DATABASE / USE oldname | Remove those lines from the file |
Unknown collation: 'utf8mb4_0900_ai_ci' | Exported from MySQL 8 | Replace with utf8mb4_unicode_ci (MySQL vs MariaDB: what’s the difference?) |
Table ... already exists | Target already has the tables | Drop existing tables, or import into an empty database |
| File too large / timeout | Above the upload or time limit | Importing a database that’s too large for phpMyAdmin |
After importing a website’s database
Update the application’s configuration with the new database name, user and password. How to change a database user’s password
Prefer to follow along?
- Back up WordPress and prove you can restore it
Intermediate · 45 min - Move a WordPress site to Traxio
Intermediate · 60 min - Export a database and import it somewhere else
Intermediate · 25 min
Looking for somewhere to run PHP and MySQL? Traxio’s PHP and MySQL hosting includes phpMyAdmin.
Common questions
How do I import a database?
Use phpMyAdmin: create an empty database first, open it, then use the Import tab to upload your .sql file. If the file is too big to upload, compress it as .gz or split it.
Spotted something out of date or unclear? Tell us and we’ll fix it.