在我的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