If you want to import the file faster than this, you can use MySQL’s LOAD DATA INFILE command, which is a command you can use to import data. When I followed the same process, it took 774.476 seconds to import (12 minutes 54 seconds). The example file I’m using here is 271,117 rows and is 41 MB. I’ll also try to import a large CSV file. So, if you’re having issues or concerns over getting the right names and data types, consider making adjustments after the table is imported. You can do this with an ALTER TABLE statement. I don’t rename any columns when importing, but I rename the columns if needed after I import. Generally to make it easier for me, I create the table when I import the CSV file. So, that’s how you can use the MySQL workbench import CSV process to import a CSV file. You can see the results in the output panel. You can then check your results by selecting from your new table. If it was successful, click Next to continue.Ī summary page is shown, letting you know how many rows were imported. The two steps shown will then be performed, and hopefully green ticks will appear next to them, indicating it was successful. You’ll then see the Import Data screen, which is essentially a confirmation screen. Once you’ve made any changes, if any, click Next. You can click on the wrench icon to change some more settings, such as: You can see a preview of the data at the bottom of the window. These are determined from the data in the column, but if it’s not right, you can change it. You can also see and change the data types for each column. Each of them has a checkbox to the left, indicating whether or not you want to import that column into the table. You can see the encoding, which in most cases you can leave as the default value. You’ll then see the Configure Import Settings page. In this example, the table is called “import_data”. This is helpful if you are importing the CSV file again and want to create the table from scratch. There’s a checkbox you can select called “Drop table if exists” if you want to drop the table before creating it. In this example, I’ll change the name from “data” to “import_data”, because I think data may be a reserved word. You can change this to whatever you want the table to be called, which might be needed if your table already exists. You can either select an existing table to import the data into or create a new table.Ĭreating a new table is selected by default, and the name is set to your filename. You’ll then see the Select Destination screen. Select the CSV you want to import by clicking the Browse button.Ĭlick Next. There’s no need to select a specific table from the Tables list. Right-click on the database you want to import data into and select Table Import Wizard.
These are from MySQL Workbench on macOS, but the Windows version looks very similar. Your window should look like this one below. I’ll try a larger CSV file at the end of this guide and measure the performance, as you’re probably importing a file with more than 3 rows.įirst, open MySQL Workbench and connect to your database. Our CSV file is a small file with some product data in it, just for demonstration purposes: id,product_name,price
Here’s how to import a CSV file using MySQL Workbench: Let’s take a look at how to import a CSV in MySQL.
But it’s up to you and depends on your data.
Personally, I like to import the CSV into a new table, then update column names and data types if needed. The process I’ll show you will allow you to create a new table when importing a CSV or use an existing table. You won’t need to have a table created, but you can create one before importing the CSV. To use the MySQL Workbench import CSV process, you’ll need a few things: I’ll show you how to do this in MySQL Workbench in this guide.
Are you working on a MySQL database and need to import CSV data?