当我执行以下查询时,它可以工作:
SELECT'INNODB_OS_LOG_WRITTEN','QUESTIONS' INTO OUTFILE'D:/orders.csv'FIELDS终止',' 包含在''' 由'\ n';
终止的线路但是当我从Windows命令提示符或使用以下命令从批处理文件调用此查询时,
“%MBIN%\ mysql.exe”-u“%MUSER%” - p“%MPASS%” - h“%MHOST%” - e“选择'INNODB_OS_LOG_WRITTEN','问题'进入'D':D:/ orders.csv'FIELDS终止','''''''''''''''''''''''
它没有运行。
粘贴下面运行上述命令时发生的事情。
C:\Documents and Settings\188931>"%MBIN%\mysql.exe" -u"%MUSER%" -p"%MPASS%" -h "
%MHOST%" -e "SELECT 'INNODB_OS_LOG_WRITTEN','QUESTIONS' INTO OUTFILE 'foldrname/
orders.csv' FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n';"
C:\Program Files\MySQL\MySQL Server 5.5\bin\mysql.exe Ver 14.14 Distrib 5.5.16,
for Win32 (x86)
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Usage: C:\Program Files\MySQL\MySQL Server 5.5\bin\mysql.exe [OPTIONS] [database
]
-?, --help Display this help and exit.
-I, --help Synonym for -?
--auto-rehash Enable automatic rehashing. One doesn't need to use
'rehash' to get table and field completion, but startup
and reconnecting may take a longer time. Disable with
--disable-auto-rehash.
(Defaults to on; use --skip-auto-rehash to disable.)
-A, --no-auto-rehash
No automatic rehashing. One has to use 'rehash' to get
table and field completion. This gives a quicker start of
mysql and disables rehashing on reconnect.
--auto-vertical-output
Automatically switch to vertical output mode if the
result is wider than the terminal width.
-B, --batch Don't use history file. Disable interactive behavior.
(Enables --silent.)
我注意到的另一件事是,当我运行以下内容时:
“%MBIN%\ mysql.exe”-u“%MUSER%” - p“%MPASS%” - h“%MHOST%” - e“SELECT'INNODB_OS_LOG_WRITTEN','QUESTIONS';”
从命令提示符或批处理文件,它正在执行(注意 - 我删除了csv导出)。
所以似乎从批处理文件(或Windows命令提示符)执行查询的组合,其中有一个OUTFILE到csv不起作用。
任何团体都可以帮助解决这个问题。
答案 0 :(得分:0)
你应该逃避" 符号 -
ENCLOSED BY '"'
改变:
ENCLOSED BY '\"'