Importing a Database via phpMyAdmin

8 views Database Management

Uploading SQL Files to Your Database

Importing a database is a common task when migrating a website from another server or restoring a backup. phpMyAdmin provides a straightforward import feature for SQL files.

Before You Begin

  • Ensure the target database already exists. If not, create it first through DirectAdmin's MySQL Management.
  • If the database is not empty and you want a clean import, consider emptying it first or ensure your SQL file includes DROP TABLE statements.
  • Check the size of your SQL file. phpMyAdmin has an upload limit (typically 50MB to 128MB depending on server configuration).

Step-by-Step Import

  1. Log in to phpMyAdmin (via DirectAdmin).
  2. Select the target database from the left sidebar.
  3. Click the Import tab at the top of the page.
  4. Click Choose File (or Browse) and select your SQL file from your computer.
  5. Leave the format set to SQL (the default).
  6. Leave the character set as utf-8 unless your database uses a different encoding.
  7. Click Go to start the import.
  8. Wait for the import to complete. You will see a success message listing the queries executed.
Do not close the browser tab or navigate away while the import is in progress. This will interrupt the process and may leave your database in an incomplete state.

Importing Large Files

If your SQL file exceeds the phpMyAdmin upload limit, try these alternatives:

  • Compress the file - phpMyAdmin can import compressed files in .zip, .gz, or .bz2 format, which are significantly smaller.
  • Split the file - Use a tool like BigDump or SQLDumpSplitter to divide the SQL file into smaller parts and import them sequentially.
  • Use SSH - If you have SSH access, import via the command line:
    mysql -u username -p database_name < /path/to/file.sql

Common Import Errors

  • Max execution time exceeded - The file is too large for the PHP timeout. Use SSH import or split the file.
  • Duplicate entry - The table already contains data with the same primary key. Empty the table first or use INSERT IGNORE.
  • Unknown collation - The SQL file uses a character collation not available on the server. Edit the file and replace the collation with utf8mb4_general_ci.
After a successful import, verify the data by browsing the tables in phpMyAdmin and testing your website to ensure everything is working correctly.
Need More Help?

Can't find what you're looking for? Our support team is ready to help.

Contact Support
Hi there! How can we help?
Chat with us