How to Import a MySQL Database using phpMyAdmin?

This article will show you how to import your MySQL database.

  1. Log in to your Hostimul cPanel account.
  2. Navigate to the Database Tools section, and select phpMyAdmin.
  3. Log in with your cPanel username and your MySQL password.
  4. In phpMyAdmin, you will see a list of your databases on the left side. Select the database you would like to import to.
  5. Once the database is selected, click the "Import" tab at the top. Note: If you import a backup file to a database that already has content, it will replace the existing content.
  6. In this subsection, a "browse" button will appear. Select this, browse to your local SQL file and click "Open." If it is a zipped file, please unzip the file first.
  7. After you have selected the file, click "Go" button at the bottom; Wait while your database imports. Depending on the size, this can take a few minutes. Note: The maximum size for a SQL upload via phpMyAdmin is 50MB. For larger databases please either split the database before importing or import via SSH.

You should get this message: Import has been successfully finished, X queries executed.

Troubleshooting

Your import file is too large!

If the database that you are trying to import is over 50 MB in size, then you will not be able to import the database through phpMyAdmin on shared servers.

Note: Users on a VPS or Dedicated server can import larger file by increasing the cPanel PHP max upload size and the cPanel PHP max POST size from WHM, under Tweak Settings.

#1044 - Access denied for user 'username1'@'localhost' to database 'user2_wrdp9'

The problem here is your import file contains an SQL query that attempts to create a database for the wrong username. Notice the user2 in 'user2_wrdp9' does not match the username1 in 'username1'@'localhost'. Its necessary to edit the import file and change the old user2 to your new username1. Here is an example of what it looks like (notice 3 places where the username is outdated):

Database: `user2_wrdp9`CREATE DATABASE `user2_wrdp9` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;USE `user2_wrdp9`;

#1049 - Unknown database 'username1_wrdp9'

This error is displayed when your import file does not have a query to create the database before importing the data. Simply go to cPanel >MySQL Databases and create a database with that name (in the example of our article, "wrdp9"). Then re-attempt your import.

#1007 - Can't create database 'username1_wrdp9'; database exists

The issue means that your import file contains an SQL query that attempts to create a database that already exists. If the database is empty, just go to cPanel >MySQL Databases and remove that empty database; then re-attempt your import. If the database is not empty, you should edit the import file and remove the CREATE DATABASE query. Here is an example of what it looks like:

CREATE DATABASE `username1_wrdp9` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;