melodrama
melodrama

Reputation: 265

Save MySQL query results into a text file

I want to save a MySQL query result to to a text file like this:

SELECT * FROM orders INTO OUTFILE '/data.txt'

However, I don't have write permission on the server. Where can I write to or is there a simpler way?

Upvotes: 19

Views: 39117

Answers (2)

Mukul Aggarwal
Mukul Aggarwal

Reputation: 1585

use this command:

mysql -uroot -p -e "select * from database_name.table_name" > filename.txt

Enter the password and all is done

Upvotes: 11

Hrithu
Hrithu

Reputation: 281

select * into outfile  'sd1.txt' from orders;

or

select * into outfile  'sd1.sql' from orders;

Upvotes: 6

Related Questions