Backup restore mysql database

`mysqldump --databases db1 db2 db3 db4 > backup.sql```

mysqldump --all-databases > backup.sql

If you get an error that says : Got a packet bigger than ‘max_allowed_packet’ bytes then increase your max allowed packet either in my.cnf or in mysql shell
mysql>set global max_allowed_packet=200*1024*1024;

Backup with Compression:

mysql -u -p | gzip -9 > backup.sql.gz

Restore from compressed backup:

gunzip < backup.sql.gz | mysql<br></br>

Backup and Restore a single table :

mysqldump -u -p database_one table_name > /var/www/backups/table_name.sql<br></br>
mysql -u -p database_two < /var/www/backups/table_name.sql```

**Backup everything including triggers and routines:**

`mysqldump --routines --all-databases > output.sql`

**Backup only stored procedure:**  
`mysqldump --routines --no-create-info --no-data --no-create-db --skip-opt > output.sql`