How to use load data local infile command

0 votes

How to run this command "LOAD DATA LOCAL INFILE" in CentOS to load a file in SQL database? I am not able to run this because I don't know where to execute it. Tried on terminal but getting command not found error. Tried adding SQL username and password as arguments but no use. So please help me out. 

Feb 4, 2019 in Big Data Hadoop by Kamal
1,011 views

1 answer to this question.

0 votes

This command should be executed in MySQL console and not in the terminal. 

First, start the MySQL service: 

sudo service mysqld start

When asked for the password, enter the password and hit Enter. To open MySQL console, run this:

mysql -u root -p

When asked for the password, enter the password and hit enter.

Next create a database:

create database <databasename>;
use <databasename>;

Replace <databasename> with the name you want for the database.

Then create a table:

create table <tablename>(<parameters>);

Now you can load the data. Refer to the following example:

LOAD DATA LOCAL INFILE 'abc.csv' INTO TABLE abc FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\r\n' IGNORE 1 LINES (col1, col2, col3, col4, col5...);
answered Feb 4, 2019 by Omkar
• 69,090 points

Related Questions In Big Data Hadoop

0 votes
2 answers

Hey for all, how to get on large data i want use in hadoop?

Hi, To work with Hadoop you can also ...READ MORE

answered Jul 30, 2019 in Big Data Hadoop by Sunny
156 views
0 votes
1 answer

How to load data from HDFS into pig relation?

Hey, To load data from HDFS to pig ...READ MORE

answered May 7, 2019 in Big Data Hadoop by Gitika
• 65,870 points
867 views
0 votes
1 answer

How to use data compression in sqoop import?

You can enable data compression from the ...READ MORE

answered May 15, 2019 in Big Data Hadoop by Rocky
856 views
0 votes
1 answer

Update hdfs data before stroring in MySql

Yes, you can update the data before ...READ MORE

answered Jan 27, 2019 in Big Data Hadoop by Omkar
• 69,090 points
148 views
0 votes
1 answer

Using Hadoop for Data Analytics.

Yes, your approach is correct - you ...READ MORE

answered Sep 28, 2018 in Big Data Hadoop by Frankie
• 9,810 points
109 views
0 votes
1 answer

How to open MySql console in Ubuntu?

sudo service mysqld restart mysql -u <username> root ...READ MORE

answered Dec 14, 2018 in Big Data Hadoop by Omkar
• 69,090 points
1,184 views
–1 vote
1 answer

Facing the below error while installing mysql in VM

We would like to say that the ...READ MORE

answered Dec 21, 2018 in Big Data Hadoop by Omkar
• 69,090 points
237 views
0 votes
1 answer

Hadoop: How to use Jps command with Sun JDK installed?

You can put JPS into your path ...READ MORE

answered Nov 9, 2018 in Big Data Hadoop by Omkar
• 69,090 points
836 views
+1 vote
1 answer

Hive: How to use insert query like SQL

It is now possible to insert like ...READ MORE

answered Nov 5, 2018 in Big Data Hadoop by Omkar
• 69,090 points
193 views