Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Mysql import and export

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

1. Backup the database: (the command is executed under the mysqlbin directory of DOS)

Mysqldump-- opt school > school.bbb

Note: back up the database school to the school.bbb file. School.bbb is a text file with any file name. Open it and you will find something new.

1. Export the entire database

Mysqldump-u user name-p database name > exported file name

Mysqldump-u root-p aikersql > aiker.sql

two。 Export a table

Mysqldump-u user name-p database name table name > exported file name

Mysqldump-u aiker-p aikersql users > aiker_users.sql

3. Export a database structure

Mysqldump-u root-p-d-- add-drop-table aikersql > d:aiker_db.sql

-d No data-- add-drop-table adds a drop table before each create statement

two。 Import database

Common source commands

Enter the mysql database console, such as mysql-u root-p

Mysql > use database

Then use the source command, followed by a script file (such as .sql used here)

Mysql > source d:aiker_db.sql

You can also use mysql-uroot-p-Ddb1

Transfer the text data to the database

1. The format that the text data should conform to: the field data is separated by tab key, and the null value is replaced by n.

Example:

3 rose Shenzhen No.2 Middle School 1976-10-10

4 mike Shenzhen No.1 Middle School 1975-12-23

2. Data input command load data local infile "file name" into table table name

Note: you'd better copy the files to the mysqlbin directory and type the library where the table is located with the use command first.

[@ more@]

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report