Mysql Data Import and Export

Source: Internet
Author: User

1. Create a database, a table, and an instance for inserting data.
Drop database if exists school; -- delete if school exists
Create Database school; -- create a database School
Use school; -- open the library school
Create Table teacher -- Create Table teacher
(
Id integer auto_increment not null primary key,
Name varchar (10) Not null
); -- End of table Creation
Insert into teacher values (null, 'T ');
Insert into teacher values (null, 'J ');
It is inconvenient to debug commands in DOS. You can write the preceding commands into a file named School. SQL, then copy it to c: \, and type the following command in the DOS window: mysql-uroot-P password <C:/school. SQL.

Ii. Import and export of. SQL files in windows.
DOS window: Start-> Run-> cmd
Import to: mysql-uroot-proot <C:/school. SQL
Export to: mysqldump-uroot-proot school> C:/school. SQL

Iii. Data Backup (the command is executed in the DOS window ):
1. Back up the database: (back up the database School)
Mysqldump-uroot-proot school> C:/school. SQL
2. Import the backup data to the database: (import back to the school database)
Mysql-uroot-proot school <C:/school. SQL
Note: At this time, the database school already exists.
Note: Another method is to enter the MySQL Database Console, use school, and then use the source commandSource C:/school. SQLYou can.

4. Import text data to the MySQL database.
1. Text data must conform to the corresponding format: field data is separated by the tab key, and the null value is replaced by \ n.
For example, a file named teacher.txt contains the following content:
\ N w
\ N h
2. Data Import commandLoad data local infile "C:/teacher.txt" into Table teacher;
Note: In the MySQL Command window, use the use command to open the database where the table is located.

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.