How to get a CSV file into mysql

Written by jim campbell
  • Share
  • Tweet
  • Share
  • Email

The MySQL Workbench is an interface used to create SQL queries. You create an SQL query to import a CSV file, which is a comma-separated file that contains several records. This is beneficial if you have several records in a CSV file, and you must create a new table from the list of records. MySQL has a SQL command that allows you to import the data with only one line of code.

Skill level:

Other People Are Reading


  1. 1

    Click the Windows "Start" button on your MySQL computer or a computer that has access to the database. Click "All Programs," then click "MySQL." Click "Workbench" to open the utility.

  2. 2

    Click the "Query" menu item at the top and select "New Query." This shortcut opens a query editor where you edit and retrieve your table data.

  3. 3

    Type the following SQL code in the editor:

    load data local infile 'myfile.csv' into table import fields terminated by ',' enclosed by '"' lines terminated by '\n' (id, name, address)

    Replace "myfile.csv" with your own CSV file name. Replace "import" with the table name you want to create. In this example, a list of customers is imported. Replace "id, name, address" with the columns you want to create in your imported table.

  4. 4

    Click the "Run" button at the top of the MySQL Workbench. The SQL statement executes and your records import into the table you specified.

Don't Miss

  • All types
  • Articles
  • Slideshows
  • Videos
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the site, you consent to the use of cookies. For more information, please see our Cookie policy.