Reputation: 159
The below query works
SELECT *
FROM some_table
LIMIT 1
INTO outfile 'some_file.txt';
but how would you write the result of this statement to file
SHOW ENGINE INNODB STATUS INTO OUTFILE 'some_file.txt'
or any other show statements, getting error using into outfile
?
Error message:
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO OUTFILE "some_file.txt"' at line 1
Upvotes: 1
Views: 1182
Reputation: 4954
You CANNOT. INTO OUTFILE can be used only with SELECT STATEMENT... hence you're getting 1064 (syntax-error). Please refer to the documentation here: https://dev.mysql.com/doc/refman/5.1/en/select-into.html
It always says-"SELECT ... INTO OUTFILE..."
You need to use console in order to get output of SHOW commands or anything apart of 'SELECT' statement. Here's how you do it:
Follow the syntax below:
mysql --user root --password=sunny -e"show databases">"D:\\test\\OutFile.txt";
Above statement will give your all the databases in outfile.
mysql --user root --password=sunny --database=mydb -e"describe myTable">"D:\\test\\OutFile.txt";
This will output the description of your table.
HTH !
Upvotes: 4