1. Home
  2. Hosting & Servers
  3. Virtual Private Server [VPS]
  4. How to Backup and or Restore your MySQL Database Using SSH
  1. Home
  2. Hosting & Servers
  3. Virtual Private Server [VPS]
  4. How to Backup and or Restore your MySQL Database Using SSH

How to Backup and or Restore your MySQL Database Using SSH

If you need to backup or restore your MySQL database via command line you can do the following to do so.  

Backup MySQL Database

Connect via SSH and run MySQL

If you need to know how to connect to via SSH you can do so by following the below KB article:How to Log into a Linux Server Using SSH

  1. Connect to the server via SSH
  2. Type PWD, this will let you know what the directory you are working in
  3. To restore the SQL file the was uploaded you can run the below command:

Please note: The -p will prompt a user to enter the database password after the command is ran

4. Once the MySQL dump has been completed the SQL file will be stored in the working directory

5. Once this is completed without errors the command line will return to the below:

6.If you require a local copy of your database you can download it via FTP. Below is a KB article on how to connect via FTP:

Restore MySQL Database

There a two steps to restore a SQL backup via command line:

  • Upload SQL file via FTP to server
  • Connect via SSH and run MySQL

Upload SQL file via FTP to server

  1. Connect to the server via FTP
  2. Locate the SQL file on your local machine
  3. Upload the file to the home directory

Connect via SSH and run MySQL

If you need to know how to connect to via SSH you can do so by following the below KB article:How to Log into a Linux Server Using SSH

  1. Connect to the server via SSH
  2. Type PWD, this will let you know what the directory you are working in
  3. To restore the SQL file the was uploaded you can run the below command:

Please note: The -p will prompt a user to enter the database password after the command is ran

4. Once this is completed without errors the command line will return to the below:

Updated on February 13, 2019

Was this article helpful?