Database backup in mysql using terminal

I usually prefer MySQL workbench to take backups and restore them. But sometimes circumstances bring forward a machine that doesn’t contain workbench. Use command line utility in that case. These backups/dumps are nothing but SQL statements.

mysqldump -u[username] -p [database_name]>[filename].sql

To restore a backup.

mysql -u[username] -p  [database_name] <[file_name].sql

If database name is not known then log into MySQL and find database using

show databases;

Categories: Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s