"C:\Program Files\MySQL\MySQL Server 5.0\bin\mysql" -uroot -psuntoyo 211 -N -e "Select concat(trim(Barcode),'|'),concat(trim(InventoryName),'|'),concat(price,'|'),trim(Description) From Inventory " > c:\\2.txt由于数据库是UTF8,所以文件编码也是UTF8,由于另外一个硬件上需要文件的编码格式为ANSI,所以怎么改?
*****************************Today is 2012-11-19
Time is 15:31:44.03*****************************
Please wait...halt your operation till backup process finishes!ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the ma
nual that corresponds to your MySQL server version for the right syntax to use n
ear 'USING gbk),convert(concat(trim(InventoryName),'|'),USING gbk),convert(conca
t(pri' at line 1
Press any key to continue . . .
SELECT
CONVERT(CONCAT(TRIM(Barcode),'|') USING gbk),CONVERT(CONCAT(TRIM(InventoryName),'|') USING gbk),CONVERT(CONCAT(price,'|') USING gbk),TRIM(Description) FROM Inventory 我在MYSQL5。5下测试没有问题
),concat(trim(InventoryName),'|'),concat(price,'|'),trim(Description) From Inven
tory " > R:\TEMP\2.txtD:\MySQL55\bin>
那就把using gbk换成latin1试试.
"C:\Program Files\MySQL\MySQL Server 5.0\bin\mysql" -uroot -psuntoyo 211 -N -e "Select Convert(concat(trim(Barcode),'|') using GBK) ,convert(concat(trim(InventoryName),'|') using GBK),convert(concat(price,'|') using GBK),convert(trim(Description) using GBK) From Inventory " > c:\\2.txt --default-character-set=latin1
这样格式为ANSI,不过导出的字为???,还是一样的问题.
不会吧,我测试了一下,库、表、字段UTF8,用CONVERT using GBK导出,中文是正常的
否则是乱码
我数据库默认就是UTF8的,正常不加--default-character-set=latin1的话是全部显示,
加的话就是????
存在123.txt的话又报错,这样客户又要抱怨.
为什么在我这边不能执行这个命令?Database backup
*****************************Today is 2012-11-20
Time is 10:31:25.37*****************************
Please wait...halt your operation till backup process finishes!ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the ma
nual that corresponds to your MySQL server version for the right syntax to use n
ear 'CHARACTER SET gbk From Inventory' at line 1
Press any key to continue . . .
"C:\Program Files\MySQL\MySQL Server 5.0\bin\mysql" -uroot -psuntoyo 211 -N -e
"Select * into outfile 'c:\\2.txt' CHARACTER SET gbk From Inventory "
//123.txt' CHARACTER SET gbk FROM `cfg_product`";D:\MySQL55\bin>
一旦是ANSI的话,就算用CONVERT也是乱码.