MySQL Data backup and restore

Source: Internet
Author: User
Tags mysql text

Add 1 million data to the text document, with 8 fields per data, respectively:

Id Int (one) NOT NULL primary key auto_increment

Name varchar (40)

Age Int (11)

Sex Char (5)

Salary Int (11)

Phone varchar (13)

Email varchar (+) NOT NULL

Address varchar (64)

How to import and export data for 1.MySQL text files

Import data: (input in MySQL console)

Load data local infile "E:/data.txt"
into table person (name,age,sex,salary,phone,email,address);

Export data: (input in MySQL console)

Select Name,age,sex,salary,phone,email,address
into outfile "E:/data_out.txt"
Lines terminated by "\ r \ n"
from person;

2. Import and export using Mysqldump.exe in MySQL (Find Mysqldump.exe in MySQL, run with Win32)

To back up the MySQL database command:

Mysqldump-uusername-ppassword databasename >e:/Backup.sql

Restore MySQL database commands (find Mysqldump.exe in MySQL, run with Win32)

(1) Mysql-uusername-ppassword DatabaseName < e:/backup.sql

(2) using the source command in the MySQL console (entered in the MySQL console)

Mysql>source E:/backup.sql

Compress the MySQL database directly (find Mysqldump.exe in MySQL and run with Win32)

Mysqldump-uusername-ppassword DatabaseName | gzip > backup.sql.gz

Backup MySQL database (find Mysqldump.exe in MySQL, run with Win32)

Mysqldump-uusername-ppassword databasename tablename > e:/backup.sql

Restore a compacted MySQL database

Gunzip < backupfile.sql.gz | Mysql-uusername-ppassword DatabaseName

3. Transfer the database to the new server

Copy the Data folder from MySQL to the new server and configure the permissions

The data in MySQL is stored in the Files folder, and the default is C:/programdata/mysql/mysql Server 5.5/data/.

You can also view it from the Mysql.ini configuration file

#Path to the database root

Datadir= "C:/programdata/mysql/mysql Server 5.5/data/"

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.