If you want to export a large database, or if you encountered difficulties exporting a database through phpMyAdmin, you can export your database using SSH by following these steps:
Step 1 - Preparation
Gather your database details: database name, user and password. If you don't remember the database password, you can change it.
Step 2 - Connect to SSH
Make sure SSH is enabled
Connect to your hosting via SSH
Open your root directory (public_html)
Step 3 - Export the Database
Use the following command to export the database:
mysqldump -u database_username -p database_name > file.sql
For example, if the parameters of your database are:
Database name: u123456789_database
Username: u123456789_admin
Exported database backup name: backup.sql
The command will look like this:
mysqldump -u u123456789_admin -p u123456789_database > backup.sql
After that, you will be prompted to enter the database password, and the exporting process will start. Keep in mind that the time it will take may vary depending on the size of your database.
That’s it! Now you know how to export your database through SSH 😊