Backup and restore of MySQL

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

MYSQLDUMP-UROOT-P ABC > ABC. SQL
(Export the database ABC to ABC.) SQL file)
When prompted for a password, enter the password for the database user name (if you export a single table, enter the table name after the database name)

If you are prompted locktable error: Then empty a grid after mysqldump-uroot-p ABC plus --skip-lock-tables

3, you will see the file news. is SQL automatically generated under the bin file?

MySQL command line Import Database:

1, which will be imported. The SQL file is moved to the bin file, which makes the path easier
2, the 1th step with the above export
3, enter mysql:mysql-u user name-P
As I entered the command line: Mysql-u root-p?? (The input will also let you enter the MySQL password)
4, create the database you want to build in Mysql-front, this is an empty database, such as a new target database named News
5, Input: Mysql>use target database name
As I entered the command line: Mysql>use news;
6, import file: mysql>source import filename;
As I entered the command line: Mysql>source news. SQL;

MySQL backup and restore is done using the mysqldump, MySQL, and source commands.
Backup and restore of MySQL under 1.win32
1.1 Backup
Start Menu | Run | cmd | Enter the Bin folder with the "CD \program Files\mysql\mysql Server 5.0\bin" command | Using the mysqldump? -u user name-P databasename >exportfilename "export the database to a file, such as Mysqldump-u root-p Voice>voice.SQL, then enter the password to start the export.
?
1.2 Restore
Enter MySQL command line Client, enter the password, enter the "mysql>", enter the command "show databases;", enter to see what database; Create the database you want to restore, enter the Voice; ", enter; switch to the newly created database, type" use voice; ", enter; Import data, enter" source voice. " sql; ", enter, start import," mysql> "again, and the restore succeeds without prompting the error.
?
Backup and restore of MySQL under 2.Linux
2.1 Backup
[[email protected] ~]# cd/var/lib/mysql (go to MySQL library directory, adjust the directory according to your MySQL installation situation)
[Email protected] mysql]# mysqldump-u root-p voice>voice. SQL, enter the password.
2.2 Restore
Law One:
[[email protected] ~]# mysql-u root-p return, enter the password, enter the MySQL console "mysql>", with 1.2 restore.
Law II:
[[email protected] ~]# cd/var/lib/mysql (go to MySQL library directory, adjust the directory according to your MySQL installation situation)
[Email protected] mysql]# mysql-u root-p voice<voice. SQL, enter the password.

Backup and restore of MySQL

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.