[SQL] Insert content file to mysql

dear all,
i want to insert string in file to mysql i just want how to do that cause i am poor in sql languages ...
so this file like this
DATA.txt

doni|student|westjava|123412|lombok|
iwan|student|westjava|1234412|utankayu|
rio|student|westjava|12342|cempedak|

so i want insert DATA.txt to table in mysql like this

table in mysql

|id| name | status | kota | phone | address |
|1|doni|student|westjava|123412|lombok|
|2|iwan|student|westjava|1234412|utankayu|
|3|rio|student|eastjava|12342|cempedak|

how i can do that if i want content in DATA.txt will insert in table like above
thx for advice

You may try something like this:

# cat /tmp/data.txt
doni|student|westjava|123412|lombok|
iwan|student|westjava|1234412|utankayu|
rio|student|westjava|12342|cempedak|
# mysql -uroot -p t
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.5.13-55-log Percona Server (GPL), Release rel20.4, Revision 138

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> create table test_t (
    -> id int(10) primary key auto_increment,
    -> name char(20),
    -> status char(20),
    -> kota char(20),
    -> phone int(20),
    -> address char(60)
    ->  );
Query OK, 0 rows affected (0.01 sec)

mysql> load data local infile '/tmp/data.txt'
    -> into table test_t
    -> fields terminated by '|'
    -> lines terminated by '\n'
    -> ( name, status, kota, phone, address );
Query OK, 3 rows affected (0.00 sec)
Records: 3  Deleted: 0  Skipped: 0  Warnings: 0

mysql> select  * from test_t;
+----+------+---------+----------+---------+----------+
| id | name | status  | kota     | phone   | address  |
+----+------+---------+----------+---------+----------+
|  1 | doni | student | westjava |  123412 | lombok   |
|  2 | iwan | student | westjava | 1234412 | utankayu |
|  3 | rio  | student | westjava |   12342 | cempedak |
+----+------+---------+----------+---------+----------+
3 rows in set (0.00 sec)

mysql>
2 Likes

@radoulov: thx for your help