MySQL: Import CSV File in Database or Table

Profile picture for user arilio666

So we are gonna import a CSV file into MySQL workbench and use its content. Comma Separated Values or CSV are the types of file formate which was used to import into the workbench.

Today in this article we will be seeing how we can import a CSV file into a created table in a workbench step by step.

Here is the CSV file that we are gonna import today.

Step 1: Select A Database

Open your workbench account and select a database that you can use.

USE Database_Name;

Step 2: Create A Table With Empty Content

Create a table in structure as same as the structure present in the CSV file.

Today we are gonna use details based on IP.

create table ip_details(ID int,
First_name varchar(50),
Last_name varchar(50),
IP varchar(40))

  • So from here we provided the table details and on how the structure is gonna be with the relevant data types.

Step 3: Importing CSV

Right-click the created table by refreshing the database and clicking on Table Data Import Wizard.

  • When we click it we can see the table import popup.
  • Click on browse and select the CSV file and double click it.
  • Click next all the way till you see this part.

When you click next now it should start importing your CSV into the table you just created in the exact structured column.

Just click finish and it is done.

Now when you query the table ip_details it should show the CSV content which will be imported into this table we just created.

Tags