首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >带Rails的MySQL通过本地安装驱动我

带Rails的MySQL通过本地安装驱动我
EN

Stack Overflow用户
提问于 2016-02-18 20:35:41
回答 1查看 205关注 0票数 1

rails 4.2.5中是否有设置让它尝试在没有密码的情况下登录来测试和开发数据库。

我面临的问题是:我不能运行rake :migrate,rake :create等命令。我不使用密码总是出错。它不是错误的密码,只是rails没有使用所提供的密码。见下文。

代码语言:javascript
复制
rake aborted!
Mysql2::Error: Access denied for user 'sharetribe'@'localhost' (using password: NO)

当我要检查database.yml密码时,密码实际上是正确的。我还通过使用相同的用户和密码从控制台运行登录到数据库来测试这一点。我还尝试删除数据库并再次创建它。这是我的database.yml

代码语言:javascript
复制
# SQLite version 3.x
#   gem install sqlite3-ruby (not necessary on OS X Leopard)
development:
    adapter: mysql2
    database: sharetribe_development
    encoding: utf8
    username: sharetribe
    password: ***********
    host: localhost

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
# The example has user root for tests to work with Travis CI
test: &test
    adapter: mysql2
    database: sharetribe_test
    encoding: utf8
    username: root
    password: **********
    host: localhost

staging:
    adapter: mysql2
    database: sharetribe_staging
    encoding: utf8
    username: sharetribe
    password: *********
    host: localhost

production:
    adapter: mysql2
    database: sharetribe_production
    encoding: utf8
    username: sharetribe
    password: ***********
    host: localhost
#    socket: /var/run/mysqld/mysqld.sock

cucumber:
  <<: *test

下面是mysql命令行的输出。

代码语言:javascript
复制
mysql> SHOW DATABASES;
+------------------------+
| Database               |
+------------------------+
| information_schema     |
| mysql                  |
| performance_schema     |
| sharetribe_development |
| sharetribe_production  |
| sharetribe_test        |
| sys                    |
+------------------------+
7 rows in set (0.01 sec)

mysql> SHOW GRANTS FOR 'sharetribe'@'localhost';
+--------------------------------------------------------------------------------+
| Grants for sharetribe@localhost                                                |
+--------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'sharetribe'@'localhost'                                 |
| GRANT ALL PRIVILEGES ON `sharetribe_development`.* TO 'sharetribe'@'localhost' |
| GRANT ALL PRIVILEGES ON `sharetribe_test`.* TO 'sharetribe'@'localhost'        |
| GRANT ALL PRIVILEGES ON `sharetribe_production`.* TO 'sharetribe'@'localhost'  |
+--------------------------------------------------------------------------------+
4 rows in set (0.01 sec)
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-02-18 20:55:05

也许您的密码在database.yml中有一些特殊字符没有正确转义。你试过把它们改得更简单吗?

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35491897

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档