Hello Readers!
MySQL have this load data function, where we can insert data to a table from external files like csv, txt etc.
The process is quite simple, 1st lets login to mysql via terminal/console.
mysql -u root -p
Enters username and password of mysql
mysql>
Now lets run the command.
mysql> LOAD DATA LOCAL INFILE /var/www/site/site_users.csv
INTO TABLE site_users FIELDS
TERMINATED BY ;
ENCLOSED BY
LINES TERMINATED BY \n
IGNORE 1 LINES;
You will see this if command ran successfully:
Query OK, 370 rows affected (0.00 sec)
Records: 370 Deleted: 0 Skipped: 0 Warnings: 0
0 Comment(s)