5

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.

New Alexandria
  • 6,951
  • 4
  • 57
  • 77

4 Answers4

11

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
Dave Swersky
  • 34,502
  • 9
  • 78
  • 118
  • 1
    Hi Dave, thanks for responding. Unfortunately that doesn't seem to work for me. ashley_baxter$ mkdir /var/lib/mysql/tmp mkdir: /var/lib/mysql: No such file or directory I've managed to get everything working nicely on my iMac, but it's my MacBook that's giving me grief. Not sure why as I've followed the same steps. –  Jun 11 '09 at 14:37
  • I had a similar problem: DESC failed on all tables - with the same error. TMP directory it was attempting to access was /tmp, which had world-writable permissions. To make things more confusing - it used to work fine! Following your steps got everything back up and running. :-) Thank you!
    – KateYoak Jul 30 '12 at 15:38
  • 1
    A couple of clarifications of the above. It should be "chown" rather than "chmod" in step 2. And in step 3, that line goes in /etc/my.cnf (at least that's where the file is in Fedora 17). But yeah, this fixed the same problem for me. – Will Ware Jan 02 '13 at 19:00
1

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

1

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.

glacier
  • 301
  • 3
  • 6
0

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*
Zsolt Szilagyi
  • 4,741
  • 4
  • 28
  • 44