• Skip to main content
  • Skip to primary sidebar
  • Advertise

Computer Tips And Tricks, Gadgets, How-To, Life - 2.0 Style

Get latest technology updates and computer tips and tricks.

Execute MySQL Query From Within Shell Script

January 4, 2016 by Gautam

To execute MySQL query in shell script, try this:


 

for localFile in `ls /usr/local/testTemp/test`; do

echo $localFile
echo “load data local infile ‘/usr/local/testTemp/test/$localFile’ into table testSqoop.test24 FIELDS TERMINATED BY 0x01 LINES TERMINATED BY ‘\n’ ( e_vi, e_vg, e_ti, e_tp, e_v, e_s, e_bsid, e_it, e_bd, e_ec, e_st, e_up);” > /usr/local/hive-0.8.1-bin/localFile.sql
mysql –user=root –password=password < /usr/local/hive-0.8.1-bin/localFile.sql

done


 

Filed Under: How To's

Primary Sidebar

Copyright © 2023 · Magazine Pro on Genesis Framework · WordPress · Log in