How to back up and restore MySQL

Source: Internet
Author: User
Tags localhost mysql mysql backup
It is important for MYSQL database users to back up and restore MySQL. This article describes how to use the mysqldump and source commands to back up and restore MYSQL in Windows and Linux. I. Backup and restoration method for MySQL in Win32 system: Enter cmd during running and use cdPro

It is important for MYSQL database users to back up and restore MySQL. This article describes how to use the mysqldump and source commands to back up and restore MYSQL in Windows and Linux. I. Backup and restoration methods for MySQL in Win32 system: Enter cmd during running and use cd/Pro

It is important for MYSQL database users to back up and restore MySQL. This article describes how to use the mysqldump and source commands to back up and restore MYSQL instances in Windows and Linux.

I. Restoration of MySQL backup in Win32 System

Backup: In "run", enter "cmd" and use "cd/Program Files/MySQL Server 5.0/bin" to enter the bin folder, enter "mysqldump-u username-p databasename> exportfilename" to export the database to a file, such as mysqldump-u root-p voice> voice. SQL, and then enter the password to start exporting MYSQL Data for backup.

Restore: Enter the MySQL Command Line Client, enter the password, go to "mysql>", enter the Command "show databases;", Press enter to see what database is there, and create the database you want to restore, enter "create database voice;", Press ENTER; switch to the database you just created, enter "use voice;", Press ENTER; import data, and enter "source voice. SQL; ", Press enter to start importing, and" mysql> "is displayed again. If no error is returned, the restoration is successful.

Ii. How to back up and restore MySQL in Linux:

Backup: [root @ localhost ~] # Cd/var/lib/mysql (go to the MySQL database directory and adjust the directory based on your MySQL installation)

[Root @ localhost mysql] # mysqldump-u root-p voice> voice. SQL. Enter the password.

Restoration: two methods are available:

Method 1: [root @ localhost ~] # Mysql-u root-p press enter and enter the password to go To the MySQL console "mysql>", which is restored in the same way as 1.2.

Method 2:

[Root @ localhost ~] # Cd/var/lib/mysql (go to the MySQL database directory and adjust the directory based on your MySQL installation)

[Root @ localhost mysql] # mysql-u root-p voice

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.