Managing databases via SSH command line

Managing databases via the SSH command line is sometimes necessary & can be faster than using the phpMyAdmin web interface. If you do not currently have SSH access on your hosting account, you will need to request it via our support department as we do not enable SSH by default for security reasons.

When using the -p flag, you will be prompted to enter the password for the username specified. This password will be the password specified when creating the database username through cPanel.

Exporting a mySQL database:

mysqldump -p -u username database_name > databasename.sql

Importing a mySQL database: 

mysql -p -u username database_name < databasefile.sql

Note: The database file (.sql extension) must be located on the server. We recommend uploading it to your /home/ directory and working from that directory. We do not recommend placing a database file into any publicly accessible directory.

An alternative to importing or exporting a database using ssh would be to use the phpMyAdmin web interface. If your database is rather large, you may find that using the ssh import/export options are better suited to perform the task.

As always, should you have any questions or problems, please feel free to submit a service ticket with our technical support department.