Open links in new tab
  1. Importing a CSV file into a MySQL table can be done using various methods, including the LOAD DATA INFILE statement and MySQL Workbench. Here’s a step-by-step guide to help you through the process.

    Using LOAD DATA INFILE Statement

    The LOAD DATA INFILE statement is a powerful way to import data from a CSV file into a MySQL table. Here’s how you can do it:

    1. Prepare the Table and CSV File: Ensure you have a table that matches the structure of your CSV file. For example, create a table named discounts: CREATE TABLE discounts ( id INT NOT NULL AUTO_INCREMENT, title VARCHAR(255) NOT NULL, expired_date DATE NOT NULL, amount DECIMAL(10, 2) NULL, PRIMARY KEY (id) );

    2. Check Secure File Privileges: Verify the directory where MySQL can read files using: SELECT @@secure_file_priv;

    3. Copy the CSV File: Place your CSV file in the directory specified by the secure_file_priv variable.

    4. Import the CSV File: Use the LOAD DATA INFILE statement to import the data: LOAD DATA INFILE 'C:/ProgramData/MySQL/MySQL Server 8.0/Uploads/discounts.csv' INTO TABLE discounts FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n' IGNORE 1 ROWS;

    5. Verify the Import: Check the data in the table to ensure it was imported correctly: SELECT * FROM discounts;

    1. How to Import a CSV File to a MySQL Database

      Sep 15, 2022 · In the MySQL database, there are two options to import a CSV file. One is to use a command line tool and another is to use a Graphical User …

    2. How to Insert a CSV File Into an SQL Table - Baeldung

      Nov 19, 2024 · In this tutorial, we’ll focus on how to import data from a CSV file into an SQL table. In particular, we’ll explore this solution in databases such as …

    3. CSV Import Database: Complete Technical Guide [2025] | CSV Viewer

      Apr 1, 2025 · Master CSV to database imports with our technical guide. Step-by-step instructions for MySQL, PostgreSQL, MongoDB and more with performance optimization techniques.

    4. Import a CSV File Into an SQLite Table - GeeksforGeeks

      Jul 23, 2025 · To create a new SQLite database, use the following command: Query: The above command will create a Database in the current working directory. …

    5. How to Import CSV File into MySQL Table in 5 Different …

      Jun 19, 2025 · Learn 5 methods to import a CSV into MySQL: command line, Workbench, phpMyAdmin, and Skyvia. Discover tips for smooth imports!

    6. Import CSV (flat file) using SQL Server Management Studio in existing ...

      Oct 5, 2021 · Open SQL Server Management Studio (SSMS): Start by launching SQL Server Management Studio on your computer. Connect to Your Database: Connect to the SQL Server instance where your …

    7. How to Import CSV Files into SQL Server: Four Reliable …

      May 21, 2025 · Importing CSV files into SQL Server is a common task, ranging from quick one-offs to part of an automated pipeline. Whether you’re loading a small …

    8. How to Import a CSV File into MySQL Table - phoenixNAP

      4 days ago · Learn how to import a CSV file into MySQL table. This guide covers 3 methods: command line, phpMyAdmin, and dbForge Studio.

    9. SQL Server Import Data from CSV into Existing Table

      1 day ago · The BULK INSERT statement is the fastest way to sql server import data from csv into existing table. It reads the file directly from the disk and pushes it …

    10. How to Import a CSV in SQL Server | DataReportive …

      Open SSMS and connect to your SQL Server instance. Right-click on the database where you want to import the CSV file. Select Tasks > Import Data... to launch the …

  1. People also ask