有一个包含以下内容的文件1.sql:
DROP TABLE IF EXISTS `tbl`;
CREATE TABLE `tbl` (
`row` varchar(100) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
INSERT INTO `tbl` VALUES ('—\'');当我在phpMyAdmin中运行它时,这个sql运行得很好。
但是当我从cmd运行它时:
mysql -u root -p dtbs < 1.sql它失败了
ERROR 1064 (42000) at line 6: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''鈥擻'')' at line 1如果您在—\'中更改了任何内容,它都会起作用。如果在—和\'之间添加letter,则可以工作:—d\'
—\'有什么特别之处?为什么我不能在cmd (windos7 7-64)的文件中使用它。它是我正在尝试恢复的转储的一部分。
发布于 2012-10-11 05:27:49
在运行代码之前,请尝试在cmd中运行命令chcp 850。
这将使1.sql文件以正确的编码加载。
发布于 2012-10-11 05:14:03
--default-character-set=utf8
做到了。
mysql -u root -p --default-character-set=utf8 dtbs < 1.sqlhttps://stackoverflow.com/questions/12828146
复制相似问题