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 Utilisateurs l'ont trouvée utile
Cette réponse était-elle pertinente?

Related Articles

MySQL will not start, “MySQL File ‘/usr/share/mysql/charsets/?.conf’ not found” in error log.

The most common cause for this error, is a failed downgrade of MySQL from 4.1 to 4.0.  Many...

Create PostgreSQL user account

It is advisable to run PostgreSQL under a separate user account. This user account should only...

Enable the full text indexing for a MSSQL database

Syntax sp_fulltext_database Initializes full-text indexing or removes all full-text catalogs...

Fix Lame Nameserver Error

A lame server, is one that is specifed at the registrar to be authoritative for a domain, but...

Install and configure DNS server in Windows Server 2003

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