简体   繁体   English

使用mysql命令行工具导入sql文件

[英]import a sql file using mysql command line tools

here is my command to import a sql file into mysql using command line 这是我的命令,使用命令行将sql文件导入mysql

mysql -p eshop < c:\xampp\mysql\eshop.sql

But there is error message 但是有错误信息

Error:
Unknown command '\x'

Error:
Unknown command '\m'

Error:
Unknown command '\e'

Anyone knows what's wrong with the command? 有人知道该命令出了什么问题吗?

Try this, I think this may help you. 试试这个,我认为这可能对您有帮助。

mysql -u username -p database_name < file.sql

check mysql Options. 检查mysql选项。 Don't use \\ (slash) use / (slash) to mention the file path. 不要使用\\ (斜杠)使用/ (斜杠)来提及文件路径。

On Windows, the pathname separator character is '\\', but MySQL treats the backslash as the escape character in strings. 在Windows上,路径名分隔符为'\\',但MySQL将反斜杠视为字符串中的转义字符。 To deal with this issue, write separators in Windows pathnames either as '/' or as '\\\\'. 要解决此问题,请在Windows路径名中将分隔符写为'/'或'\\\\'。 To load a file named C:\\mydata\\data.txt, specify the filename as shown in either of the following statements: 要加载名为C:\\ mydata \\ data.txt的文件,请指定以下两个语句之一所示的文件名:

mysql  <database_name> < ‘C:/mydata/data.txt’
mysql  <database_name> < ‘C:\\mydata\\data.txt’

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM