Hosting Knowledge Base

Home » Knowledge Base » Control Panel » Advanced Tools » Database Manager » How to import a database?

Knowledge Base

How to import a database?

Importing a database can be accomplished in many ways, however, the easiest are through phpMyAdmin or SSH.

phpMyAdmin
The phpMyAdmin method requires you to access your database through the Control Panel -> Database Manager section and from the “All Databases” tab use the “phpMyAdmin” link available in the “Management” column for your database. Once you log into phpMyAdmin, select “Import” from the navigation pane and select your “Import” options, then click “Go”.

SSH
Before you connect with SSH, you need to create an SSH account. You can use the How to create an SSH account guide.
The SSH method requires you to first successfully connect through SSH (You can use the How to connect through SSH? guide) and then you can execute the following command to import your database:

mysql -h DB_HOST -u DB_USER -pDB_PASS DB_NAME < /home/www/database.sql

The variables DB_HOST, DB_USER, DB_PASS and DB_NAME should be replaced with the settings of your database and database.sql with the exact path to the .sql file you will be importing data from. You can find your database settings in your Control Panel -> Database Manager section, select “Options” for your database and choose the “Information” tab.

 

In case you receive an error during the import, stating that you do not have permissions to CREATE or USE this database, you should make some slight modifications to your database.sql file before you retry the import. You need to remove the CREATE DATABASE and USE commands at the first lines of your database.sql file. The lines in question are shown below. Be advised that for phpMyAdmin you need to remove the CREATE DATABASE line and update the USE line so it uses your MySQL user listed in the MySQL Manager section of your Control Panel.

−− CREATE DATABASE DB_NAME DEFAULT CHARACTER SET XXXX COLLATE XXXX;
−− USE DB_USER;