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

  • Email, SSL
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Install and configure DNS server in Windows Server 2003

Solution Install DNS 1. Open Windows Components Wizard. To do so, use the following...

How to Install MRTG

Solution Steps for MRTG installation are documented as MRTG Installation Make sure MRTG is NOT...

How is Linux Licensed?

Linus has placed the Linux kernel under the GNU General Public License, which basically means...

Execute a SQL script (.sql file) on MsSql Server database

To execute a .sql file, you need to open the “Query Analyzer” Start -> Programs ->...

How does memory overcommit affect PostgreSQL?

In Linux 2.4 and later, the default virtual memory behavior is not optimal for PostgreSQL....