How to import and export database via SSH
You can easily import/export your database using PHPMyAdmin menu in cPanel. To do so, please, follow the instructions here. But it allows to process only the databases that do not exceed 50Mb. If your database is bigger you will need to use SSH commands.
Shell access is disabled on shared servers by default so if shell access was not enabled for your account previously, first of all, please, submit a ticket at our HelpDesk using Hosting – Support department with request to enable jailed shell for your account.
The next step is to log in your account via SSH. This tutorial will guide you through this process.
Please, note that before performing export or import, you will need to assign a database to a user. You can do it in cPanel in the menu ‘MySQL Databases’ under the section ‘Add User To Database’. You can find more instructions on database creation and assigning it to the user here.
To import the database, please, use the following command:
mysql -u username –ppassword database_name < /path/to/file/file.sql
For export, please, use this one:
mysqldump -u username –ppassword database_name > /path/to/file/file.sql , where the variable in italics are the following:
username – the name of a database user assigned to this database ( it should be in the format CPANELUSERNAME_DATABASEUSER ), or your cPanel username
password – the database user password ( if you use a database user as username ), or your cPanel password ( if you use cPanel username as username )
NB! No space between -p key and password if you enter it in the command.
database_name – the name of your database, you are importing to or exporting from. It should be created in your cPanel. The format is the following: CPANELUSERNAME_DATABASENAME
/path/to/file/file.sql – the path to the mysql dump, that you are importing to ( then a new file will be created ) or exporting from your cPanel account. Here you can use both relative and absolute path formats. If you are located in the folder with the file you can just type the file name with the extension. With absolute path, for example, it will be the following:
/home/CPANEL_USERNAME/public_html/database.sql
If you do not receive any error or notification after pressing Enter, it means that the command was performed successfully.
Let us provide with an example.
We will use the following settings:
username – nctest_tutorial ( as a database user ), nctest ( as a cPanel username )
password – 123qwe
database_name – nctest_database
path to the file – /home/nctest/public_html/databases/tutorial.sql
After defining all the variables, the command will look the following way:
Database import:
mysql –u nctest –p123qwe nctest_database < /home/nctest/public_html/databases/tutorial.sql
![]()
NB! you can also use the following command:
mysql –u nctest –p nctest_database < /home/nctest/public_html/databases/tutorial.sql
this way, you need to enter the password in the next line.
Database export:
mysqldump –u nctest –p123qwe nctest_database > /home/nctest/public_html/databases/tutorial.sql

NB! you can also use the following command:
mysqldump –u nctest –p nctest_database < /home/nctest/public_html/databases/tutorial.sql
this way, you need to enter the password in the next line.
Should any issues encounter, please, do not hesitate to contact our support team via HelpDesk.
