Let's say that you have the following text, where the fields are delimited by the "|" character, the name of the database is "company" and the name of the table you're importing to is "contact":
Code: Select all
Name|Address|Phone#
The command you would use to import the data is:
mysqlimport --fields-terminated-by="|" --password company contact
Whatever user your currently logged in as, will be the user that the command will run under.
If all you want to do is import a certain field, say names, you can do that too - let's say that the text file looks like this:
Code: Select all
Smith, John|Eves, Ernie|Doe, Jane
mysqlimport -c Names --lines-terminated-by="|" --password company contact
(If you had each name on a separate line, you wouldn't need to bother with the "--lines-separated-by" bit.)
To delete any previous entries in the table, you can add a "-d" switch to the command line.