Connecting Tech Pros Worldwide Help | Site Map

data dump

Ike
Guest
 
Posts: n/a
#1: Dec 9 '06
Here's a dumb question, but I am unable to find the relevant spot in the
online docs, and am coming to the group asking my (pathetically) little dumb
question (which I should know the answer to!)

I can take data into a database from an sql file with:

mysql -u USER -p DBNAME < dump.sql

But how do I send data out of an sql table, to an sql-type text file? Don't
I simple change the redirection symbol from "less than," to "greater to," as
follows:

mysql -u USER -p DBNAME dump.sql

Whenever I do this, however, it just hangs (even on tiny databases, so I
must have something syntactically wrong here). Can anyone point me in the
right direction on this please? Thanks, Ike


Aggro
Guest
 
Posts: n/a
#2: Dec 9 '06

re: data dump


Ike wrote:
Quote:
I can take data into a database from an sql file with:
>
mysql -u USER -p DBNAME < dump.sql
>
But how do I send data out of an sql table, to an sql-type text file? Don't
I simple change the redirection symbol from "less than," to "greater to," as
follows:
>
mysql -u USER -p DBNAME dump.sql
No, you will use another program for that purpose:

mysqldump -u USER -p DBNAME dump.sql
Aggro
Guest
 
Posts: n/a
#3: Dec 9 '06

re: data dump


Aggro wrote:
Quote:
No, you will use another program for that purpose:
>
mysqldump -u USER -p DBNAME dump.sql
If you wonder why. The program itself has no way of knowing that you
placed after the command. It would do the same thing even if you don't
put it. So if you try:
mysqldump -u USER -p DBNAME

It will just print out the dump on the screen, instead of the file. This
is why another command must be used for this purpose.
Michael Austin
Guest
 
Posts: n/a
#4: Dec 10 '06

re: data dump


Aggro wrote:
Quote:
Ike wrote:
>
Quote:
>I can take data into a database from an sql file with:
>>
>mysql -u USER -p DBNAME < dump.sql
>>
>But how do I send data out of an sql table, to an sql-type text file?
>Don't I simple change the redirection symbol from "less than," to
>"greater to," as follows:
>>
>mysql -u USER -p DBNAME dump.sql
>
>
No, you will use another program for that purpose:
>
mysqldump -u USER -p DBNAME dump.sql

What format do you want the data to be in? do you want something that looks
like the actual insert statement or do you just want the data (delimited or
concatenated...) you have not give us much information to go on.

"mysqldump" is used to extract the database structure as well as the insert
statements for the data in the database - not data only. I find mysqldump to
quite archaic in its implementation. A real database engine that I am familiar
with has the ability to un

again, what do you want to achieve? what is the problem you are trying to solve?

--
Michael Austin.
Database Consultant
Closed Thread