How to import and export MySQL databases using SSH commands
Since there is a 2GB limit for uploading and downloading databases in the phpMyAdmin environment, and there may be errors on the web browser side, it is recommended to use the SSH command line to export and import databases more securely.
Preparation
- Make sure that your database user has access rights to the database you want to export or import in the My Zone MySQL/MariaDB Database management:
- Create an SSH connection to your virtual server. You can find instructions on how to do this here.
Database export
The database export command is:
mysqldump -uUSERNAME -p DATABASE > backup.sql
USERNAME replace with your database username
DATABASE replace with the name of the database to be exported
backup.sql is the name of the database file to be exported. If necessary, it can be changed to suit you.
After the command is run, it will ask for the user password of the database you entered. Once the password has been set, the export process begins, the time required for which depends on the size of the database.
Database import
The database import command is:
mysql -h host.mysql.zonevs.eu -uUSERNAME -p DATABASE < backup.sql
host.mysql.zonevs.eu replace with your domain MySQL server address
USERNAME replace with your database username
DATABASE replace with the name of the database to be exported
backup.sql is the name of the database file to import in this example. It must be located in the same directory as you are currently using.
After the command is run, it will ask for the user password of the database you entered. After entering the password, the import process begins, the time required for which depends on the size of the database.