Showing posts with label mysql. Show all posts
Showing posts with label mysql. Show all posts

Friday 7 September 2012

Import data into MySQL database using mysqlimport

The below example shows how to import data into mysql database using mysqlimport utility. We are importing data from a text file to mysql database.

mysqlimport utility is a stand-alone command line utility program which comes with MySQL.

First you have to connect to mysql server.
1. open command prompt
2. change directory to the path of mysql bin folder (for example C:\xampp\mysql\bin)











Create a database employee and use that database.







create a table employee with 2 fields id and name







create a text file for employee table with fields delimited by tab.This file is used for importing data into employee table.

employee.txt

1    Tom
2    pinky
3    Ram

put the employee.txt file into C:\xampp\mysql\data\employee folder.
In mysqlimport, the name of the data file should match the name of the table.  

close the mysql connection by typing exit






open a new command prompt and change directory to the path of mysql bin folder (for example C:\xampp\mysql\bin)
Type mysqlimport command 









This will import the employee details from the text file into employee table.