MySQL Error 1 (HY000) Trouble creating file Errcode 2

自作多情 提交于 2019-12-18 07:10:09

问题


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:

ERROR 1 (HY000): Can't create/write to file '/usr/local/mysql/data/test_development/users.MYI' (Errcode: 2)

It's worth mentioning I'm a total newbie, btw.


回答1:


This forum post seems to deal with the same problem:

Try the following:

  1. mkdir /var/lib/mysql/tmp
  2. chown mysql:mysql /var/lib/mysql/tmp
  3. Add the following line into the [mysqld] section: tmpdir = /var/lib/mysql/tmp
  4. Restart the server



回答2:


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.




回答3:


I got this error in Windows, and I find out that I rename my DB name similarly. it solved my problem. Hope this helps.




回答4:


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

sudo rm /tmp/\#sql*


来源:https://stackoverflow.com/questions/981029/mysql-error-1-hy000-trouble-creating-file-errcode-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!