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.

How-to guideBeginner2 min readUpdated

Before importing

  • Create the database first in Account Manager then 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 then 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

Looking for somewhere to run PHP and MySQL? Traxio’s free PHP MySQL hosting includes phpMyAdmin and is free for your first 30 days.

Popular

Tip: press / to search from any pageSee all results