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
- Connect to the server via SSH
- Type PWD, this will let you know what the directory you are working in
- 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
- Connect to the server via FTP
- Locate the SQL file on your local machine
- 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
- Connect to the server via SSH
- Type PWD, this will let you know what the directory you are working in
- 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: