Mysql database backup and restoration command _ MySQL

Source: Internet
Author: User
Mysql database backup and restoration command Linux as 5.5 MySQL 5.0 database backup and recovery:

1. use the mysqldump command for backup:
In the Command prompt window (note that it is not the MySQL Command Line Client window of MySQL), enter,
Mysqldump-hlocalhost-uroot-proot temp> temp_2011. SQL
Mysqldump-hlocalhost-u root-proot temp> temp_2011. SQL
Mysqldump-h localhost-u root-proot temp> temp_2011. SQL
First, go to the directory where MySQL wants to store the backup file (which is easy to store the generated *. SQL file ).

You can also specify the directory to be stored in the command: for example, to store it in the root directory, the command is as follows:

Mysqldump-h localhost-u root-proot temp> temp_2011. SQL>/2011. SQL

The-h and-u parameter names and parameter values can be separated by or without spaces,

However, The-p parameter must not contain spaces between the parameter name and the parameter value. you can also enter the following:
Mysqldump-hlocalhost-uroot-p temp> temp_2011. SQL
Enter password: root
You can also enter the password later.
-H indicates that the backup database is on the local machine,-u indicates the user name,-p indicates the password, temp indicates the database name, and the backup data table can be specified later.
The generated temp_2011. SQL file automatically exists in the specified directory.


2. use the mysql command to restore:
Mysql-hlocalhost-uroot-proot temp <temp_20071106. SQL
After you enter this command, the data in the database will be restored to the backup data.
Note: During recovery, temp must exist, and the database can be empty. during recovery, the table to be restored will be automatically deleted, re-created, and inserted data.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.