- User ID
- 1
- Joined
- 7 Jan 2019
- Messages
- 1,505
- Reaction score
- 120
- Points
- 63
In order to back up your database via SSH or Telnet you will require 2 things:
For most hosting companies, this will bring you into the FTP root folder.
Type in the following to create a backup in the current directory:
Or to create a backup in a separate directory (signified by /path/to/) type:
You will be prompted for the database password. Enter it and the database will backup.
If your hosting company has you on a remote MySQL server, such as mysql.yourhost.com, you will need to add the servername to the command line. The servername will be the same as in your config.php. The command line will be:
Current directory:
Separate directory:
You can then, if you wish, download the backup to your home computer.
This tutorial also works with MariaDB.
Related tutorial: Restoring MySQL database via SSH/Telnet
- SSH or Telnet access to your site. You will need to check with your hosting company to see if this is available.
- An SSH/Telnet Client, such as PuTTY.
For most hosting companies, this will bring you into the FTP root folder.
Type in the following to create a backup in the current directory:
Bash:
mysqldump --opt -Q -u dbusername -p databasename > backupname.sql
Bash:
mysqldump --opt -Q -u dbusername -p databasename > /path/to/backupname.sql
If your hosting company has you on a remote MySQL server, such as mysql.yourhost.com, you will need to add the servername to the command line. The servername will be the same as in your config.php. The command line will be:
Current directory:
Bash:
mysqldump --opt -Q -h servername -u dbusername -p databasename > backupname.sql
Bash:
mysqldump --opt -Q -h servername -u dbusername -p databasename > /path/to/backupname.sql
You can then, if you wish, download the backup to your home computer.
This tutorial also works with MariaDB.
Related tutorial: Restoring MySQL database via SSH/Telnet