当我执行以下查询时,它可以工作:
在OUTFILE 'D:/orders.csv‘字段中选择’INNODB_OS_LOG_ LINES‘、’问句‘以’结束‘、’由‘行以’\n‘结尾;
,但当我使用以下命令从windows命令提示符或批处理文件调用此查询时,
"%MBIN%\mysql.exe“-u%MUSER%”-p"%MPASS%“-h "%MHOST%”-e“选择‘INNODB_OS_LOG_ LINES ',’问句‘进入OUTFILE 'D:/orders.csv’字段以‘终止’,‘行以’\n‘结尾;
,它没有在运行。
在下面粘贴当我运行上面的命令时会发生什么。
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“选择'INNODB_OS_LOG_WRITTEN',‘问题’;
从命令提示符或批处理文件开始执行(注意-我删除了csv导出).
因此,似乎是从批处理文件(或windows命令提示符)执行查询的组合,该命令提示符的OUTFILE到csv不起作用。
有人能帮上忙吗。
发布于 2012-10-26 06:35:01
你应该转义"符号“-
ENCLOSED BY '"'改为:
ENCLOSED BY '\"'https://stackoverflow.com/questions/13081426
复制相似问题