Steps to take backup of MySQL database via command line

kumkumsharma

Administrator
Staff member
It’s the quick and easy method to take backup of database via command line.

First connect Mysql server to command line with below command.

Code:
mysql -uusername -p // Replace username with your username.
After that enter Mysql user password and then press enter. To check the database name of which you want to take backup then you have to enter below command.

Code:
Show databases.
Now you want to take backup of database named “mysqldatabase”.

Code:
mysqldump mysql-database > mysqldatabase-backup.sql
From previous command we have backup database mysqldatabase into mysqldatabase-backup.sql.

Code:
mysqldump --databases mysqldatabaseone mysqldatabasetwo mysqldatabasethree > database-backups.sql
With this command we have combine all three databases like mysqldatabaseone mysqldatabasetwo mysqldatabasethree into sql dump file database-backup.sql.
 
Top