问题
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:
- 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
回答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