Posts tagged ‘mysql’

Extract sample dataset from a mysql database using mysqldump

mysqldump --opt --where="true LIMIT 1000000" mydb > mydb1M.sql

    On 1 specific table:
mysqldump --opt --where="true LIMIT 1000000" mydb mytable > mydb_mytable_1M.sql
    Restore:

mysql -p mydb_1 < mydb1M.sql

Load .csv file in MySQL

LOAD DATA LOCAL INFILE 'file.csv'
INTO TABLE my_table
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n'
(field_a, field_b, field_c, field_d);