Skip to content Skip to sidebar Skip to footer

Command Line MySQL Query Export Output To File Not Working In Windows

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 t

Solution 1:

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.


Post a Comment for "Command Line MySQL Query Export Output To File Not Working In Windows"