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 MySQL 5.5 mysqlimport

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

Common parameters of mysqlimport:

-- user=user_name,-u user name that connects to the Mysql server

-- password [= password],-p password

-- host=hostname,-h the host where the connected MySQL server resides

-- port=port_num, the TCP/IP port number of the-P connection

-- socket=path,-S for connections to hosts, socket files used by Unix, named pipes used by Windows

-- default-character-set=charset_name default character set

-- delete,-D clear the table before importing the text file. This option should be carefully selected.

-- force,-f ignores errors. For example, if part of the import in the text file does not match the table to be imported, the import operation will continue with the import of other matching parts and will not be terminated; if this parameter is not available, mysqlimport will exit the import

-- ignore,-I if there are duplicate values during import, the duplicate values will be skipped

-- replace,-r if there are duplicate values in the import process, the duplicate values will be overwritten

-- local,-L reads the input file locally on the client

-- lock-tables,-l lock all tables to be written before importing the text file

-- silent,-s silent mode. The result will be output only if an error occurs

-- ignore-lines=N skips the first N lines in the text file

When use-threads=N imports a text file, it uses several parallel threads

-- Delimiter in fields-terminated-by imported text file

-- fields-enclosed-by specifies the symbol used to contain column values, which is useful for character columns, or for scenarios with column delimiters in the middle of characters

-Import exampl

-- View the contents of the imported text file, whose name is the same as the table name to be imported

[root@localhost fire] # cat / tmp/t_test.txt

10,ACCOUNTING,NEW YORK

20,RESEARCH,DALLAS

30,SALES,CHICAGO

40,OPERATIONS,BOSTON

50,MAINTENANCE,HULUDAO

-- Import text files

[root@localhost fire] # / software/bin/mysqlimport-usystem-p "Mysql#2015"-S / data/mysql.sock fire-- default-character-set=gbk-- fields-terminated-by=',' / tmp/t_test.txt

Fire.t_test: Records: 5 Deleted: 0 Skipped: 0 Warnings: 0

-- create tables

Mysql > CREATE TABLE `t_ test` (

-> `deptno` int (11) NOT NULL DEFAULT'0'

-> `dname` varchar (15) NOT NULL

-> `loc` varchar (15) NOT NULL

->) ENGINE=innodb DEFAULT CHARSET=utf8

Query OK, 0 rows affected (0.18 sec)

-- View the imported content

Mysql > select * from t_test

+-+

| | deptno | dname | loc | |

+-+

| | 10 | ACCOUNTING | NEW YORK |

| | 20 | RESEARCH | DALLAS |

| | 30 | SALES | CHICAGO |

| | 40 | OPERATIONS | BOSTON |

| | 50 | MAINTENANCE | HULUDAO |

+-+

5 rows in set (0.00 sec)

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