简体   繁体   中英

Mysql2 Error on Rails Migration

On rake db:migrate I get the error:

Mysql2::Error: Can't read dir of './site_development/' (errno: 13): SHOW TABLES

Current versions of installed shenanigans:

From MySQL install bundle: mysql Ver 14.14 Distrib 5.5.12, for osx10.6 (i386) using readline 5.1

From RVM: ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.7.0]; Rails 3.0.7; Mysql2 0.2.7

I'm aware certain permissions need to be updated, but I'm not quite sure which ones.

Is your database named site_development by any chance? If so, this might help:

Determine what your mysql data directory is. For me, it is /usr/local/mysql/data . sudo ls -l that bad-boy. I bet you'll find a directory named site_development that is owned by root (or some user other than the _mysql user). For me, all the mysql data dirs are owned by _mysql:wheel . Do you have another database that is working properly? See what the ownership on that table is in the data directory, and make sure that site_development matches.

I suspect that if you run mysql from the command line, and try to select something from a table in that database, you'll see a similar error. If not, let us know what your db name is, what the permissions are on your mysql data directory.

If you're not sure where your mysql data dir is, try typing which mysql . That should show you where the mysql binary is, it should be in a PATH_PREFIX/mysql/bin/mysql director. The data directory should be a sibling of bin , so it would be PATH_PREFIX/mysql/data .

For Mac OS, run

sudo chown -R mysql:mysql /usr/local/mysql*

User mysql should have write access to mysql data directory.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM