Get the App
SLTechnology News&Howtos  ›  Database  › 

How to import data to mysql using mysqlimport

Shulou Source: shulou.com Published: 2022-05-31 15:59:53 10月02日 Update

This article will explain in detail how to use mysqlimport to import data into mysql. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.

1. Prepare to import data

[root@D2-LZY245 ~] # cat / tmp/emp.txt

100,Steven,King,24000.00

101,Neena,Kochhar,17000.00

102,Lex,De Haan,17000.00

103,Alexander,Hunold,9000.00

104,Bruce,Ernst,6000.00

105,David,Austin,4800.00

106,Valli,Pataballa,4800.00

107,Diana,Lorentz,4200.00

108,Nancy,Greenberg,12008.00

109,Daniel,Faviet,9000.00

110,John,Chen,8200.00

2. Create InnoDB engine table

Mysql > create database test1

Query OK, 1 row affected (0.00 sec)

Mysql > use test1

Database changed

Mysql > create table emp (

-> employee_id int (10)

> first_name varchar (50)

> last_name varchar (50)

-> salary decimal (10jue 2) engine=innodb charset=utf8

Query OK, 0 rows affected (0.00 sec)

3. Import data

[root@D2-LZY245] # mysqlimport-uroot-pendant 123456' test1-- default-character-set=utf8-- fields-terminated-by=',' / tmp/emp.txt

Mysqlimport: [Warning] Using a password on the command line interface can be insecure.

Test1.emp: Records: 11 Deleted: 0 Skipped: 0 Warnings: 0

4. View the results

Mysql > select * from emp

+-+

| | employee_id | first_name | last_name | salary | |

+-+

| | 100 | Steven | King | 24000.00 | |

| | 101 | Neena | Kochhar | 17000.00 | |

| | 102 | Lex | De Haan | 17000.00 | |

| | 103 | Alexander | Hunold | 9000.00 | |

| | 104 | Bruce | Ernst | 6000.00 | |

| | 105 | David | Austin | 4800.00 | |

| | 106 | Valli | Pataballa | 4800.00 | |

| | 107 | Diana | Lorentz | 4200.00 | |

| | 108 | Nancy | Greenberg | 12008.00 | |

| | 109 | Daniel | Faviet | 9000.00 | |

| | 110 | John | Chen | 8200.00 | |

+-+

11 rows in set (0.00 sec)

This is the end of this article on "how to import data into mysql using mysqlimport". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it out for more people to see.

Tags: Data articles more good practical content engine article knowledge results preparation reference help related Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology NVidia Apple Xiaomi Huawei