How MySQL backs up and restores

Source: Internet
Author: User
Tags localhost mysql mysql backup mysql command line mysql database backup

Using MySQL database friends, backup and restore of MySQL is more important. The important thing to do simply, today we use the mysqldump and source commands to back up the restore, divided into Windows and Linux under the MySQL backup and restore operations.

The backup and restore method of MySQL under Win32 system

Backup: Enter "cmd" in "Run", use "Cd/program files/mysql/mysql Server 5.0/bin" to enter the Bin folder, enter "Mysqldump-u user name-P databasename > Exportfilename "Export the database to a file, such as Mysqldump-u root-p voice>voice.sql, and then enter a password to start exporting MySQL data and implementing backup operations."

Restore: Enter the MySQL command line Client, enter the password, enter the "mysql>", enter the command "show databases;", carriage return, see what some database; Create the database you want to restore, type create Voice; ", carriage return; switch to the newly established database, type" use voice; ", enter the data, enter" source voice.sql; ", carriage return, start the import, reappear" mysql> "and restore success without prompting for an error.

Second, Linux under the MySQL backup and restore methods:

Backup: [root@localhost ~]# cd/var/lib/mysql (go to MySQL library directory, adjust directory according to your MySQL installation)

[Root@localhost mysql]# mysqldump-u root-p voice>voice.sql, enter the password.

Restore: There are two ways to choose:

The first method: [root@localhost ~]# mysql-u root-p carriage return, enter the password, enter the MySQL console "mysql>", restore with 1.2.

The second method:

[Root@localhost ~]# cd/var/lib/mysql (access to MySQL library directory, adjust directory according to your MySQL installation situation)

[Root@localhost mysql]# Mysql-u root-p Voice

Related Article

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.