rails 4.2.5中是否有设置让它尝试在没有密码的情况下登录来测试和开发数据库。
我面临的问题是:我不能运行rake :migrate,rake :create等命令。我不使用密码总是出错。它不是错误的密码,只是rails没有使用所提供的密码。见下文。
rake aborted!
Mysql2::Error: Access denied for user 'sharetribe'@'localhost' (using password: NO)当我要检查database.yml密码时,密码实际上是正确的。我还通过使用相同的用户和密码从控制台运行登录到数据库来测试这一点。我还尝试删除数据库并再次创建它。这是我的database.yml
# 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命令行的输出。
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)发布于 2016-02-18 20:55:05
也许您的密码在database.yml中有一些特殊字符没有正确转义。你试过把它们改得更简单吗?
https://stackoverflow.com/questions/35491897
复制相似问题