# How to generate a MySQL backup using mysqldump

### 1. Access the server via SSH

ssh user@your_server

\
![](https://support2.scriptcase.net/rails/active_storage/blobs/redirect/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBbGxSIiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--0c1f82a20dc9a6e5472d88b73108ccbfa98f2b57/unnamed.webp)

### 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


![](https://support2.scriptcase.net/rails/active_storage/blobs/redirect/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBbHBSIiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--d135e66b74acca2caf2a0c0985fa79504d3b0cf8/unnamed%20(1).webp)

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.


