What is SSH?
SSH is a safe way to type commands on a remote server. You open it with a program such as Terminal on Mac and Linux, or PowerShell or PuTTY on Windows. Ask Hostvento support whether SSH is on for your plan.
A database holds your site's data. Exporting means saving it into a file. Importing means loading a file back in. The file usually ends in .sql.
Export a database
- Log in to your server with SSH.
- Run this command. Replace the names with yours:
This copies the database named dbname into a file called backup.sql in the current folder.mysqldump -u username -p dbname > backup.sql - Type your database password when asked. Nothing shows as you type. That is normal.
- Check the file exists with
ls -lh backup.sql. It shows the file and its size.
To make a smaller file, compress it while exporting:
mysqldump -u username -p dbname | gzip > backup.sql.gz
Import a database
First upload your .sql file to the server. You can use File Manager in cPanel or an FTP program. FTP is a way of sending files to a server.
The target database must already exist. If not, create it first in cPanel under MySQL Databases.
Warning: An import can overwrite tables with the same names. Take a backup of the target database first.
- Log in with SSH and go to the folder holding the file. Use
cd foldername. - Run:
This reads the file and loads it into dbname.mysql -u username -p dbname < backup.sql - Type the password when asked.
- Wait until the prompt returns. No message usually means success.
For a compressed file:
gunzip < backup.sql.gz | mysql -u username -p dbname
> sends data into a file (export). The arrow < reads data from a file (import).Hit a problem? Open a support ticket.
Quick recap
- Export with
mysqldump, and import withmysql. - The database must exist before you import.
- Remember which way the arrow points.
- Back up before overwriting.