我有一个标准的Rails3环境,RVM 1.2.9,Rails 3.0.5,Ruby 1.9.2p180,MySQL2 Gem 0.2.7,mysql-5.5.10-osx10.6-x86_64
运行rake db:migrate创建数据库时出现的错误是:
rake db:migrate
Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
config / database.yml有
development: adapter: mysql2 host: localhost username: root password: xxxx database: xxxx
确保这是我想念的简单事情。
首先,找到您的套接字文件:
mysqladmin variables | grep socket
对我来说,这给出了:
| socket | /tmp/mysql.sock |
然后,在您的添加一行config/database.yml:
config/database.yml
development: adapter: mysql2 host: localhost username: root password: xxxx database: xxxx socket: /tmp/mysql.sock