我遇到了一件有点奇怪的事情。我正在从 Windows 上的文件名运行我的查询
喜欢source c:\sql\general.sql
,但那失败了
mysql> source c:\sql\general.sql
--------------
mysql Ver 14.14 Distrib 5.6.11, for Win32 (x86)
Connection id: 6
Current database: joins
Current user: root@localhost
SSL: Not in use
Using delimiter: ;
Server version: 5.6.11 MySQL Community Server (GPL)
Protocol version: 10
Connection: localhost via TCP/IP
Server characterset: utf8
Db characterset: utf8
Client characterset: cp850
Conn. characterset: cp850
TCP port: 3306
Uptime: 5 days 2 hours 53 min 45 sec
Threads: 1 Questions: 167 Slow queries: 0 Opens: 86 Flush tables: 1 Open ta
bles: 62 Queries per second avg: 0.000
--------------
ERROR 1064 (42000): 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 'sourc
e c:ql' at line 1
->
这是查询
CREATE TABLE mytable (
id INT NOT NULL AUTO_INCREMENT,
name varchar(50) NOT NULL,
PRIMARY KEY (id)
);
但是,当我尝试运行相同的查询但这次命名我的文件时stuff.sql
mysql> source c:\sql\stuff.sql
Query OK, 0 rows affected (0.65 sec)
这是一个常见的错误吗?
更新
source c:\sql\\general.sql
产生此错误
mysql> source c:\sql\\general.sql
--------------
mysql Ver 14.14 Distrib 5.6.11, for Win32 (x86)
Connection id: 6
Current database: joins
Current user: root@localhost
SSL: Not in use
Using delimiter: ;
Server version: 5.6.11 MySQL Community Server (GPL)
Protocol version: 10
Connection: localhost via TCP/IP
Server characterset: utf8
Db characterset: utf8
Client characterset: cp850
Conn. characterset: cp850
TCP port: 3306
Uptime: 5 days 3 hours 42 min 4 sec
Threads: 1 Questions: 192 Slow queries: 0 Opens: 97 Flush tables: 1 Open ta
bles: 62 Queries per second avg: 0.000
--------------
ERROR:
Unknown command '\\'.
-> ;
ERROR 1064 (42000): 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 'sourc
e c:ql\\general.sql' at line 1
mysql>