To backup a MySQL database we need to know a name of the specific database we would liken to backup. Let's assume that we are going to backup a database named mysql-data.

$ mysqldump -u root -p mysql-data  mysql-data-backup.sql

The previous command will dump / backup database mysql-data into a file mysql-data-backup.sql. -u option specifies a user with access to the mysql-data database and -p option will prompt for a root password.
To restore a MySQL database from a backup file the following linux command can be used:

$ mysql -u root -p mysql-data < mysql-data-backup.sql

This will restore a database from a backup file to a destination database mysql-data. Usage of -p and -u options with mysql command is the same as in previous command.

FIND LATEST LINUX JOBS on LinuxCareers.com
Submit your RESUME, create a JOB ALERT or subscribe to RSS feed.
LINUX CAREER NEWSLETTER
Subscribe to NEWSLETTER and receive latest news, jobs, career advice and tutorials.
DO YOU NEED ADDITIONAL HELP?
Get extra help by visiting our LINUX FORUM or simply use comments below.

You may also be interested in: