How to generate a MySQL backup using mysqldump

Á

Álvaro Moura

Last updated on Jul 13, 2026

How to generate a MySQL backup using mysqldump

1. Access the server via SSH

ssh user@your_server


2. Run the command to generate the backup

mysqldump -u user -p database_name > backup.sql

  1. user → MySQL username

  2. database_name → the database you want to export

  3. backup.sql → the name of the file that will be generated

  1. After running the command, the terminal will ask for the MySQL password.
    Type it and press Enter.

  2. Important: nothing will appear while typing the password — this is normal.

3. Wait for the process to finish

The command will generate the backup.sql file in the same directory where it was executed.

4. Download the file to your local machine (optional)

If you want to copy the backup to your local machine, use:

scp user@your_server:/path/backup.sql .

  1. Replace /path/backup.sql with the correct path where the file was saved.

  2. The final dot (.) indicates that the file will be downloaded to the current directory.