How To Get a CSV File into MySQL
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.
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.
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.
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.
Click the "Run" button at the top of the MySQL Workbench. The SQL statement executes and your records import into the table you specified.