MySQL 错误 1 (HY000) 无法创建文件 Errcode 2
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/981029/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
MySQL Error 1 (HY000) Trouble creating file Errcode 2
提问by Dave Swersky
I'm having issues creating a table for my ruby on rails app. It's driving me crazy! The following is returned when I try to create the table:
我在为 ruby on rails 应用程序创建表格时遇到问题。这让我疯狂!当我尝试创建表时返回以下内容:
ERROR 1 (HY000): Can't create/write to file '/usr/local/mysql/data/test_development/users.MYI' (Errcode: 2)
错误 1 (HY000):无法创建/写入文件“/usr/local/mysql/data/test_development/users.MYI”(错误代码:2)
It's worth mentioning I'm a total newbie, btw.
值得一提的是,我是个新手,顺便说一句。
回答by Dave Swersky
This forum postseems to deal with the same problem:
这个论坛帖子似乎处理了同样的问题:
Try the following:
- mkdir /var/lib/mysql/tmp
- chown mysql:mysql /var/lib/mysql/tmp
- Add the following line into the [mysqld] section: tmpdir = /var/lib/mysql/tmp
- Restart the server
请尝试以下操作:
- mkdir /var/lib/mysql/tmp
- chown mysql:mysql /var/lib/mysql/tmp
- 将以下行添加到 [mysqld] 部分:tmpdir = /var/lib/mysql/tmp
- 重启服务器
回答by D??ng Minh Th?ng
I got this error in Windows, and I find out that I rename my DB name similarly. it solved my problem. Hope this helps.
我在 Windows 中遇到了这个错误,我发现我以类似的方式重命名了我的数据库名称。它解决了我的问题。希望这可以帮助。
回答by glacier
I hope you got this resolved as it has been a year. But I just ran into this same problem and resolved it successfully. This error is because mysql does not have permission to modify files in /usr/local/mysql/data. To bypass using this directory, this was to copy out one of the provided cnf in /usr/local/mysql/support-files into ~/.my.cnf. I used my-medium.cnf. Then I added the variable tmpdir=/tmp under the section [mysqld]. I picked /tmp because I have read and write permissions there. Remember to start and restart your mysql server.
我希望你能解决这个问题,因为已经一年了。但我刚刚遇到了同样的问题并成功解决了它。这个错误是因为mysql没有权限修改/usr/local/mysql/data中的文件。要绕过使用此目录,这是将 /usr/local/mysql/support-files 中提供的 cnf 之一复制到 ~/.my.cnf 中。我使用了 my-medium.cnf。然后我在 [mysqld] 部分下添加了变量 tmpdir=/tmp。我选择 /tmp 是因为我在那里有读写权限。请记住启动并重新启动您的 mysql 服务器。
回答by Zsolt Szilagyi
No need to restart the server
无需重启服务器
The following can work, and is worth a try: Using root privileges, search /tmp for a file named like #sql_d5_0.MYD If found, just move or delete is. That way you release the lock that keeps mysql from accesing your data. It′s
以下方法可行,值得一试: 使用 root 权限,在 /tmp 中搜索名为 #sql_d5_0.MYD 的文件,如果找到,则移动或删除即可。这样您就可以释放阻止 mysql 访问您的数据的锁。它的
sudo rm /tmp/\#sql*