Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Importing a csv into mysql via command line

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 121
    Comment on it

    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)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: