rails连接到Mysql时“访问被拒绝”

时间:2014-01-21 14:57:14

标签: mysql ruby-on-rails

我已经完成了几个地方提到的所有程序,我也从lynda.com视频教程中学到了。我使用Mac 10.7并安装了rubystack。我创建了数据库,添加并检查了database.yml,你可以再次看到它。

development:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  host: localhost
  database: simplecmsdevelopment
  pool: 5
  username: simple_cms
  password: maiwandj
  socket: /tmp/mysql.sock

因此,当我运行rake db:schema:dump时会打印以下错误

bash-3.2$ rake db:schema:dump
/Applications/rubystack-1.9.3-18/ruby/lib/ruby/gems/1.9.1/gems/bundler-1.5.2/lib/bundler/runtime.rb:220: warning: Insecure world writable dir /usr/local/bin in PATH, mode 040777
rake aborted!
Access denied for user 'simplecms'@'localhost' (using password: YES)
/Applications/rubystack-1.9.3-18/simplecms/config/environment.rb:5:in `' Tasks: TOP => db:schema:dump => environment (See full trace by running task with --trace)

3 个答案:

答案 0 :(得分:1)

您是否已在该数据库上授予该用户的权限?即,GRANT ALL PRIVILEGES ON simplecmsdevelopment.* TO simple_cms@localhost;

答案 1 :(得分:0)

您需要为simplecmsdevelopment的{​​{1}}数据库授予权限:

simple_cms@localhost

您可能希望将目录权限更改为GRANT ALL PRIVILEGES ON 'simplecmsdevelopment'.* TO 'simple_cms'@'localhost';的755 ...这应该可以修复警告。

答案 2 :(得分:0)

DB yml配置文件提到用户名:simple_cms,但是控制台中的错误消息提到用户'simplecms'@'localhost'....我建议你重写db yml配置。我猜你的用户名 'simplecms'可能用于测试环境 ....最有可能....做检查......