Note: You will need to have shell access enabled to follow this guide. Once SSH is enabled, use this guide to log in via SSH.
Step 1 - Upload the .sql file onto the server. The file must be in .sql format. It must not be compressed in a .zip or .tar.gz file.
Step 2 - If you haven't already done so, create the MySQL database via cPanel >> Databases. Create the database user and assign it to the database.
Step 3 - Using SSH, navigate to the directory containing your .sql file.
Step 4 - Run this command, replacing username with the database username and database_name with the name of the database. If you don't know these details, you can find them in the configuration file for your CMS or reset the database password via cPanel >> Databases.
Replace file.sql with the path to your sql file. You may wish to use the absolute path for added clarity (e.g. '/home/cpuser/file.sql').
mysql -p -u username database_name < file.sql
Step 5 - You will be prompted for the database user's password. Type this here then press Enter on your keyboard- note that the password will not show up as you type.
==========
To import a single table into an existing database you would use the following command, replacing details as above:
mysql -u username -p -D database_name < tableName.sql
Step 1 - Log in via SSH.
Step 2 - Enter the following command, replacing 'username' with the database username and 'database_name' with the name of the database. If you don't know these details, you can find them in the configuration file for your CMS or reset the database password via cPanel >> Databases:
We'd also recommend replacing 'database_name.sql' with the database's name for ease of management.
mysqldump -p -u username database_name > database_name.sql
Step 3 - You will be prompted for a password. Type in the database user's password and press Enter on your keyboard. Note that the password will not show up as you type.
The file database_name.sql will be generated in your current directory. This file can then be downloaded or exported via SSH or via the cPanel File Manager.
==========
To export a single table from your database you would use the following command:
As before, you would need to replace the username, database and tableName with the correct information.
mysqldump -p --user=username database_name tableName > tableName.sql
Once done, the table specified will then be saved to your current SSH directory as tableName.sql.