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.

Guide2 min readLast updated
On this page
  1. Before importing
  2. Steps
  3. Common errors
  4. After importing a website’s database
  5. Common questions

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

  1. Open Extra Features › phpMyAdmin.
  2. Select the target database in the left sidebar.
  3. Open Import.
  4. Choose your .sql or .sql.gz file.
  5. Leave the format as SQL and select Import.

A success message lists how many queries ran.

Common errors

ErrorCauseFix
No database selectedImported without selecting a database firstSelect the database, then import
#1044 Access denied ... to database 'oldname'File contains CREATE DATABASE / USE oldnameRemove those lines from the file
Unknown collation: 'utf8mb4_0900_ai_ci'Exported from MySQL 8Replace with utf8mb4_unicode_ci (MySQL vs MariaDB: what’s the difference?)
Table ... already existsTarget already has the tablesDrop existing tables, or import into an empty database
File too large / timeoutAbove the upload or time limitImporting 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?

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.

Keep going