Home >Database >Mysql Tutorial >How Can I Import Data from a Text File into My MySQL Database?
Importing Data from a Text File into a MySQL Database
To import data from a text file into your MySQL database, you can utilize the LOAD DATA INFILE command. Here's a step-by-step guide:
Step 1: Prepare your text file
Review the contents of your text file and ensure it contains the data in a tab-delimited format, with one row per line.
Step 2: Establish a MySQL connection
Connect to your MySQL database using a client tool like MySQL Workbench or the MySQL command line.
Step 3: Execute the LOAD DATA INFILE command
Execute the following command in the MySQL query editor:
LOAD DATA INFILE '/path/to/your/text_file.txt' INTO TABLE PerformanceReport;
Replace "/path/to/your/text_file.txt" with the actual path to your text file.
Step 4: Verify the import
After executing the command, check if the data was successfully imported by running the following query:
SELECT * FROM PerformanceReport;
This will display all the rows in your PerformanceReport table to confirm the import.
The above is the detailed content of How Can I Import Data from a Text File into My MySQL Database?. For more information, please follow other related articles on the PHP Chinese website!