简体   繁体   English

将数据加载到Mysql数据库中

[英]Loading Data into Mysql database

I have a text file which i would want to load into mysql database on Ubuntu server 12.04 LTS. 我有一个文本文件,我想将其加载到Ubuntu服务器12.04 LTS上的mysql数据库中。 I have entered the data into the file trey.txt and i moved the file to /tmp directory. 我已将数据输入到文件trey.txt中,并将文件移至/ tmp目录。 When i move to the db, and enter the command 当我移到数据库时,输入命令

LOAD DATA
INFILE '/tmp/trey.txt'
into table arp_table
columns terminated by '|';
the output is

 ERROR 13(HY000):Can't get stat of '/tmp/trey.txt'(Errcode: 2)

How should i modify to enter these details. 我应该如何修改以输入这些详细信息。 And can i run this from command line as a cron job. 我可以从命令行作为cron作业运行它吗?

Put your data file in root folder after that run the command 运行命令后,将数据文件放在根文件夹中

$ sudo mysql -u root -p <database name>

mysql> LOAD DATA LOCAL INFILE '/path/trey.txt' INTO TABLE pet;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM