Articles on: Dedicated Servers

Importing and Exporting databases via SSH

PHPMyAdmin will sometimes timeout when trying to import/export databases due to the sizes, here you can learn how to import/export without needing to use PHPMyAdmin.


Exporting a database


  1. Log into your dedicated server via SSH
  2. Run the command mysqldump -u <username> -h <host> -p <database name> > file.sql This will connect to the database and export it in the file called file.sql
  3. Replace the details above accordingly with the database details you are looking to export and don't include <>, except for the one before file.sql.
  4. Hit enter and then type the password for the user to gain access to the database.
  5. Then wait for it to finish, then the database has been exporting correctly.


Importing a database


  1. Log into your dedicated server via SSH
  2. Run the command mysql -u <username> -h <host> -p <database name> < file.sql This will connect to the database and import the file called file.sql
  3. Replace the details above accordingly with the database details you are looking to export and don't include <>, except for the one before file.sql.
  4. Hit enter and then type the password for the user to gain access to the database.
  5. Then wait for it to finish, then the database has been exporting correctly.


Download an export from your dedicated server


  1. Download an FTP Client such as: https://filezilla-project.org/download.php?type=client
  2. Enter the following details to login:
  • Host: sftp://"The machines IP address"
  • Username: root
  • Password: Your root SSH password.
  1. Download the .sql file by dragging it from the right window to the left to begin the download.



You can now succesfully transfer databases between different hosts.

Updated on: 30/01/2021

Was this article helpful?

Share your feedback

Cancel

Thank you!