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 Корисниците го најдоа ова како корисно
Дали Ви помогна овој одговор?

Related Articles

Manage Database Roles

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

Export the data from different tables in our shared SQL environment?

Using Enterprise Manager Expand SQL Server group Expand the server name Expand Databases...

Change the root password for a *nix server

In order to change the root password login to the server as root and type the following, then...

Change the DNS servers for the network interfaces on my Windows server

In Network Connections, right-click the local area connection, and then click Properties. In...

Installation of Geotrust True Site Icon

Installation of True Site icon: Per the subscriber agreement, you are required to install the...