Backing up and restoring a MySQL database from the command line

. Shell into your box as root, then:
mysqldump -a -u USERNAME -p DATABASE > FILENAME.mysql

You will be prompted for your database password and then the DATABASE will be dumped to a plain-text file called FILENAME.mysql.
The resulting file, FILENAME.mysql, is a full backup with which you can fully restore your database in case of problems.

Restoring via the command line
1. Drop the database
mysqladmin -u USERNAME -p drop DATABASE

2. Recreate the database
mysqladmin -u USERNAME -p create DATABASE

3. Import the backup data
mysql -u USERNAME -p DATABASE < FILENAME.mysql

  • 1 Users Found This Useful
Was this answer helpful?

Related Articles

Manage Database Roles

Solution Database roles are conceptually completely separate from operating system users....

Manage Tablespaces

Tablespaces in PostgreSQL allow database administrators to define locations in the file system...

ColdFusion DSN parameters are not updated

SYMPTOMS New CF DSN records are created.  Even the set of parameters is tried to be updated...

Finding what packages are installed on a Linux system

For distributions that use RPM format packages, use the command: $ rpm -qa You may want to pipe...

What platforms does Linux support?

Linux runs on almost every general-purpose computer made in the last 10 years. It runs on systems...