D&C Lug - Home Page
Devon & Cornwall Linux Users' Group

[ Date Index ][ Thread Index ]
[ <= Previous by date / thread ] [ Next by date / thread => ]

Re: [LUG] loading a txt file into a mysql database



On Saturday 23 Aug 2003 7:55 pm, Luke Hinds wrote:
> Hi All,
>
> Just trying to teach myself 'mysql' by reading through the
> documentation. What i wish to do is to load some data from a txt file
> into a table.

After starting mysql or from the command line?

Command line:
mysql -u<user> -p < ./file.sql

mysql> \. ./file.sql

> In the doc it suggests:
>
> load data local infile "file.txt" into table tablename;
>
> Anyone know what syntax to use when you need to specify a directory
> path? 

mysql -u<user> -p < /home/luke/Documents/mysql/file.sql

mysql> \. /home/luke/Documents/mysql/file.sql


> Need to know what to do if the file resides elsewhere, like another host
> even (local is enough for now).

Not tried that. May be better to copy file.sql to a local filesystem - at 
least then you can be sure that the SQL references the correct database. Many 
SQL dump files don't specify the database to use and you need to put it on 
the command line or issue the use <database> from the mysql> prompt.


-- 

Neil Williams
=============
http://www.codehelp.co.uk
http://www.dclug.org.uk

http://www.biglumber.com/x/web?qs=0x8801094A28BCB3E3

Attachment: pgp00049.pgp
Description: signature


Lynx friendly