MySQL Tutorials - Herong's Tutorial Examples - v4.46, by Herong Yang
mysqlimport - Loading Data from Files
This section provides some tutorial examples on how to use mysqlimport tool to load data of to tables on a MySQL server from data files.
What Is mysqlimport? mysqlimport is a tool to load data stored in files into tables. Data should be stored in files as tab delimited values. Data file names without extensions should match table names. The command line syntax of mysqlimport is:
herong> %mysql%\bin\mysqlimport db_name file_1, file_2, ...
For example, I used the following command to load data back into the book table. Remember the data was dumped earlier by the mysqldump command with the --tab option.
herong> type Library\book.txt 1 Java 1 2 C++ 1 3 FORTRAN 2 herong> %mysql%\bin\mysqlimport --user=root --password=TopSecret \ Library Library\book.txt Library.book: Records: 3 Deleted: 0 Skipped: 0 Warnings: 0
Here is how I verified the import result:
herong> %mysql%\bin\mysql.exe --user=root --password Enter password: TopSecret mysql> use Library Database changed mysql> select * from book; +------+---------+-----------+ | ID | Title | Author_ID | +------+---------+-----------+ | 1 | Java | 1 | | 2 | C++ | 1 | | 3 | FORTRAN | 2 | | 1 | Java | 1 | | 2 | C++ | 1 | | 3 | FORTRAN | 2 | +------+---------+-----------+ 6 rows in set (0.00 sec)
Okay. 3 extra records were imported correctly.
Table of Contents
MySQL Introduction and Installation
►Introduction of MySQL Programs
mysqld - The MySQL Server Program
mysqladmin - The Client Tool for Administrators
mysql - The Client Tool for End Users
Using "mysql" Command to Run SQL Statements
mysqldump - Dumping Data to Files
--secure-file-priv="" - MySQL Server Option
►mysqlimport - Loading Data from Files
Perl Programs and MySQL Servers
Java Programs and MySQL Servers
Character Strings and Bit Strings
Table Column Types for Different Types of Values
Using DDL to Create Tables and Indexes
Using DML to Insert, Update and Delete Records
Using SELECT to Query Database
Window Functions for Statistical Analysis
Use Index for Better Performance
Transaction Management and Isolation Levels
Defining and Calling Stored Procedures
Variables, Loops and Cursors Used in Stored Procedures
System, User-Defined and Stored Procedure Variables
Storage Engines in MySQL Server
InnoDB Storage Engine - Primary and Secondary Indexes
Performance Tuning and Optimization
Installing MySQL Server on Linux