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 Utilizadores acharam útil
Esta resposta foi útil?

Related Articles

Install Microsoft SQL Server

The installation of Microsoft SQL Server, like that of various modern products is fairly easy,...

Restore a database on SQL Server using .mdf, .ldf and .ndf files?

You need to attach the database rather than perform a restore. Using Enterprise Manager: Expand...

After restoring a SQL Server database, it show a status of “Loading”

Getting the database out of LOADING state When restoring multiple backups, each backup needs...

Create a backup file of a SQL Server database?

Open Enterprise Manager and expand the registered SQL Server Expand Databases Right-click on...

Manage Database Roles

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