Learn What Errcode: 2
You can use the perror
utility to find what error 2 means:
$ perror 2 OS error code 2: No such file or directory
Additional information can be found at the @Jocelyn link mentioned in their comment: http://dev.mysql.com/doc/refman/5.5/en/cannot-create.html
Find out which path ./
points to
Now we know that the file does not exist (or perhaps it cannot be written.) The error message gives us the relative path ./
, which makes it complicated ... Wouldn’t it be useful if it displays a fully qualified path? Yes.
Therefore, when MySQL imports an SQL file, it creates several temporary files in the file system. The path is usually specified by the "tmpfile" configuration parameter in the my.cnf
MySQL my.cnf
. You can quickly find the value by running the SQL query:
$ mysql -h127.0.0.1 -uroot -p
Make sure the directory is writable by mysql
According to tmpdir, this means that MySQL was trying to create /tmp/dbnamehere/db.opt
. Make sure that this directory exists and that mysql:mysql
belongs to it. You may need to use sudo
to raise privileges sufficient to create some directories.
$ chown -R mysql:mysql /tmp/dbnamehere
Still not working? Try using other default tmpdir paths
I hit problems on my system (Ubuntu 12.04 + Vagrant 1.7.2 + Chef 11.something + opscode mysql cookbook 6.0.6 ), where the value in tmpdir
not considered or deduced from the expected.
MySQL actually tried to create a temporary file in one of the following places:
- / var / lib / mysql / dbnamehere
- / var / lib / mysql default / dbnamehere
I had to create these directories and change the ownership of mysql: mysql.
source share