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

Introduction to the method of exporting and importing data by Mysql

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

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces "Mysql export import data method introduction", in the daily operation, I believe many people in Mysql export import data method introduction problem there are doubts, Xiaobian consulted all kinds of information, sorted out simple and easy to use operation method, hope to answer "Mysql export import data method introduction" doubts helpful! Next, please follow the small series to learn together!

export data

** Execute commands directly in the system:

Export to cvs format:

[root@slave ~]# mysql -u root -p Password-e "select * from mydb.name into outfile '/tmp/12.cvs' character set utf8" --character set utf8 Specify the corresponding encoding rules, otherwise it may be garbled

Export to txt format:

[root@slave ~]# mysql -u root -p password-e "select * from mydb.name into outfile '/tmp/12.txt' character set utf8 lines terminated by '\r\n' "--When exported to txt file, without lines terminated by '\r\n' (ending character) will be like a ball of hemp under windows...

In mysql:

Export to cvs format:

mysql> select * from mydb.name into outfile '/tmp/12.cvs' character set utf8; - --character set utf8 Specify the corresponding encoding rule, otherwise it may be garbled

Export to txt format:

mysql> select * from mydb.name into outfile '/tmp/12.txt' character set utf8 lines terminated by '\r\n'; --When exporting to txt file, without lines terminated by '\r\n' (terminator) Under windows it will look like a ball of hemp...

Export to cvs format, open with WPS, quite perfect!

import data

mysql import:

mysql>load data infile '/tmp/12.txt' into table name character set uft8; --character set utf8 Specify the corresponding encoding rule, otherwise it may be garbled

Execute commands directly in the system:

[root@slave ~]# mysql -u root -p password-e load data infile '/tmp/12.txt' into table name character set uft8; --character set utf8 Specify the corresponding encoding rule, otherwise it may be garbled

Encountered a problem:emun type field, does not import data???

Solution:

Import, export add two parameters: fields terminated by and optionally enclosed by

mysql> select * from name into outfile '/tmp/11.txt' character set utf8 fields terminated by '\、' optionally enclosed by '\"' ;

mysql> load data infile '/tmp/11.txt' into table nn character set utf8 fields terminated by '\、' optionally enclosed by '\"' ;

At this point, the study on "Mysql export import data method introduction" is over, I hope to solve everyone's doubts. Theory and practice can better match to help you learn, go and try it! If you want to continue learning more relevant knowledge, please continue to pay attention to the website, Xiaobian will continue to strive to bring more practical articles for everyone!

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

Database

Wechat

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

12
Report