Version of mysql is mysql Ver 14.14 Distrib 5.5.53, for Win64 (AMD64)
After running below commands, the output still goes to stdout
mysql -uroot -proot DBinstance
select * from tablename\G INTO OUTFILE 'c:\users\12345\Downloads\some_non_existingfile'
What is the problem with above command?
Edit:
I get below error after re-correcting the select query:
ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv opti
on so it cannot execute this statement
mysql> SHOW VARIABLES LIKE "secure_file_priv";
+------------------+-------+
| Variable_name | Value |
+------------------+-------+
| secure_file_priv | NULL |
+------------------+-------+
1 row in set (0.00 sec)
Currently G:\..\mysql> dir have folders bin, data, lib, scripts & tmp.
解决方案
remove the \G flag.
select * from tablename INTO OUTFILE 'c:\users\12345\Downloads\some_non_existingfile'
you also need to make sure that
The MySQL server is not running with the --secure-file-priv option
to allow for writing output to a folder
add or amend your mysql config file (my.ini) by adding/amending the following line.
secure-file-priv = ""
or
secure-file-priv = "FOLDER-PATH-OF-YOUR-CHOICE"
then restart the mysql server using
net stop mysql
net start mysql
little info about the setting
If empty, the variable has no effect.
If set to the name of a directory, the server limits import and export operations to work only with files in that directory. The directory must exist; the server will not create it.
If set to NULL, the server disables import and export operations. This value is permitted as of MySQL 5.7.6.