Mar 17

Importing CSV to mysql

Category: mysql

Something pretty straight forward..

if i have a csv as shown below

to import to mysql
1) go to the directory of the csv file. e.g. words.csv

“airy”
“amused”
“animated”
“beatific”
“blissful”
“blithe”
“bright”
“brisk”
“buoyant”
“cheerful”

3) go into mysql admin

mysql -u root -p

4) run command

>LOAD DATA INFILE “./words.csv” INTO TABLE happy FIELDS TERMINATED BY “,” OPTIONALLY ENCLOSED BY “”"” TERMINATED BY ‘\n’;

the words.csv is saved under /var/lib/mysql.

5) and its done.

mysql> select * from happy;

+—————-+
| name            |
+—————-+
| airy                |
| amused        |
| animated      |
| beatific          |
| blissful           |
| blithe             |
| bright            |

VN:F [1.9.6_1107]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.6_1107]
Rating: 0 (from 0 votes)
DiggTwitterTechnorati FavoritesRedditNewsVineFacebookShare

Related posts:

  1. Unable to connect to the database:The MySQL adapter “mysql” is not available. Unable to connect to the database:The MySQL adapter "mysql" is...
  2. MySql Error in ubuntu solving mysql error of error 1045 Access denied for user...
  3. Import and Export Mysql Database Importing and Exporting Mysql Database...

Tags: , ,

Leave a Comment

Get Adobe Flash playerPlugin by wpburn.com wordpress themes