在我的Rails应用程序我有这样的配置数据库的MySQL:拒绝访问用户
adapter: mysql2
host: *****
username: *****
password: <%= ENV['MYSQL_PW'] %>
database: *****
encoding: utf8
timeout: 5000
pool: 5
它在服务器正常使用。但是最近出现了一个错误,我试图访问轨控制台,但我得到这个错误
Access denied for user '****' (using password: NO) (Mysql2::Error).
我也我试图运行迁移和我再次得到同样的错误。我不明白这里有什么问题。我该如何解决这个问题? 另外我该如何检查在Unix环境变量中是否设置了ENV['MYSQL_PW']
?
这是我的日志
$ rake db:migrate
DEPRECATION WARNING: The configuration option `config.serve_static_assets` has been renamed to `config.serve_static_files` to clarify its role (it merely enables serving everything in the `public` folder and is unrelated to the asset pipeline). The `serve_static_assets` alias will be removed in Rails 5.0. Please migrate your configuration files accordingly. (called from block in <top (required)> at)
DEPRECATION WARNING: You did not specify a `log_level` in `production.rb`. Currently, the default value for `log_level` is `:info` for the production environment and `:debug` in all other environments. In Rails 5 the default value will be unified to `:debug` across all environments. To preserve the current setting, add the following line to your `production.rb`:
config.log_level = :info
. (called from block in tsort_each)
rake aborted!
Mysql2::Error: Access denied for user '****' (using password: NO)
你100%确定的环境变量“MYSQL_PW”的设置是否正确?你可以仔细检查它在终端的价值吗? – RichardAE
尝试粘贴密码而不是<%= ENV ['MYSQL_PW']%>并查看它是否有效 –
@RichardAE如何在终端中检查其值?我在终端尝试了ENV ['MYSQL_PW']'和'ENV,但是它没有找到命令。 – asdlfkjlkj