April 29, 2025 - 23:19
Backing Up MySQL via SSH Image
Databases

Backing Up MySQL via SSH

Comments

Don’t even ask whether you can back up and restore MySQL databases via SSH on a Linux server — of course you can! As long as you know the MySQL root password, it’s possible. Note that your SSH root password and your MySQL root password are typically different. Here are some basic example commands for backing up and restoring MySQL databases. (NOTE: When you run the commands, a password prompt will appear — enter your MySQL root password.)

Backing Up a Database

To back up a single database:

GENEL
mysqldump -u root -p database_name > database_name.sql

To back up multiple databases:

GENEL
mysqldump -u root -p --databases database1 database2 > databases.sql

To back up all databases:

GENEL
mysqldump -u root -p --all-databases > all_databases.sql

To back up a specific table within a database:

GENEL
mysqldump -u root -p database_name table_name > table_name.sql

To back up and compress the dump at the same time:

GENEL
mysqldump -u root -p database_name | gzip > database_name.sql.gz

To back up only the data (no table structure):

GENEL
mysqldump -u root -p --no-create-info database_name > data_only.sql

To back up only the table structure (no data):

GENEL
mysqldump -u root -p --no-data schema_only > schema_only.sql

How to Restore from Backup

To restore a database from backup:

GENEL
mysql -u root -p database_name < database_name.sql

To restore a single database from a full backup:

GENEL
mysql -u root -p --one-database database_name < all_databases.sql

Related Articles

Comments ()

No comments yet. Be the first to comment!

Leave a Comment