https://stackoverflow.com/questions/17025494/source-error-2
Question
When i try to source an sql file i get the error:
mysql> source C:/Users/tom/Documents/insert.sql
ERROR:
Failed to open file 'C:/Users/tom/Documents/insert.sql', error: 2
I have checked the file path, which looks fine to me. I have also tried . C:/Users/etc
I am trying to source the sql file which holds insert statements for particular tables. All the statements in the file work when entered manually. What else could i be doing wrong?
Have tried using both backslash and forward slash when using this command
当我尝试运行一个sql文件时我得到了这样一个错误
mysql> source C:/Users/tom/Documents/insert.sql
ERROR: Failed to open file 'C:/Users/tom/Documents/insert.sql', error: 2
打开'C:/Users/tom/Documents/insert.sql'文件失败了,错误代码2
我检查了文件路径,路径是正确的,我也尝试了. C:/Users/etc
我想源文件保存插入特定表的SQL文件。手动输入文件中的所有语句。其他我还有什么做错了?
在你使用此命令时,已经尝试了使用反斜杠和正斜杠
Answer
Probably a problem of access right on the file (the file is being accessed by the mysqld server process, not yourself). Try placing the file into the data folder of MySQL, then import it from this location. The location of data folder depends on your distribution and on your own configuration.
Alternatively, feed the SQL script directly to your mysql client's stdin:
mysql [all relevant options] your_database < C:\path\to\your\script.sql
可能是文件访问权限问题(文件正在被mysqld服务器进程访问,而不是你自己)。尝试将文件放入MySQL的数据文件夹,然后从这个位置导入。数据文件夹的位置取决于您的分配和您自己的配置。
或者,将SQL脚本直接提供给mysql客户端stdin:
mysql [all relevant options] your_database < C:\path\to\your\script.sql