Mindbend.org

Mindblog

Welcome to my Blog!

Techblog

Information should be free, accurate, and available. I will be updating this section most often, enjoy!

Portfolio

Various galleries of artwork and photography I have done over the last five years.

Scripts

Mini scripts I have written and decided to share. Mostly oneliners for managing network and system load.

Mindware

Software projects are in the works and will be here eventually!

Contact

You can contact me through various methods.

Importing Mysql Files

This is a quick guide to importing Mysql flat files into a database.

Importing the data

Connecting to the database and importing from mysqldump files

$ mysql -u dbuser -pPassword -o < dbfile.sql
$

As long as the .sql file is formatted with commands, the previous line will work just fine. This allows you to simply execute the lines of code from within the file. But what if the file is a CSV file?

$ mysql -u dbuser -pPassword
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 172

mysql> load data local infile 'dbfile.txt' 
   -> into table tblproducts fields terminated by '\t'
   -> lines terminated by '\n';

This will import the data into the table organized by tabs seperated by new lines.

Importing Mysql Files
Written by:Robert Church
Published on:06-06-2009

Quick Byte

With a good conscience our only sure reward, with history the final
judge of our deeds, let us go forth to lead the land we love, asking
His Blessing and his help but knowing that here on earth, God's work
must truly be our own.
-- John F. Kennedy