1.

SQLSTATE[HY000] [1045] Access denied for user の対処

編集
この記事の要点
  • Laravel の SQLSTATE[HY000] [1045] Access denied for user
  • 原因: .env の DB_USERNAME / DB_PASSWORD が DB 側と不一致
  • 対処1: .env の値を確認 → php artisan config:clear
  • 対処2: MySQL 側でユーザ権限を再付与: GRANT ALL ON db.* TO 'user'@'localhost' IDENTIFIED BY 'pass';

 

エラー内容

SQLSTATE[HY000] [1045] Access denied for user 'homestead'@'localhost'

 

発生条件

以下のコマンドを実行。

php artisan migrate

 

対処法

データベースの接続設定に誤りがあります。

ルートディレクトリ直下の.envファイルのDB設定情報を適切なものに変更しましょう。

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret

 

編集
Post Share
子ページ

子ページはありません

同階層のページ
  1. SQLSTATE[HY000] [1045] Access denied for user 'homestead'@'localhost'
  2. Add [~] to fillable property to allow mass assignment on [App\~].
  3. PHP Parse error: syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in ~
  4. Changing columns for table "~" requires Doctrine DBAL; install "doctrine/dbal"
  5. MethodNotAllowedHttpException No message
  6. Class 'Doctrine\DBAL\Driver\PDOMySql\Driver' not found
  7. production.ERROR: No application encryption key has been specified.
  8. Dotenv values containing spaces must be surrounded by quotes.
  9. Laravel \ Socialite \ Two \ InvalidStateException
  10. The page has expired due to inactivity. Please refresh and try again.
  11. Failed to clone https://github.com/symfony/thanks.git via https, ssh protocol
  12. Illegal offset type
  13. Cannot access protected property Illuminate\Http\Request::$...
  14. Emitted value instead of an instance of Error
  15. 画像保存時にInternal Server Error
  16. Failed to authenticate on SMTP server with username ...
  17. PostTooLargeException
  18. Database hosts array is empty.
  19. Invalid request (Unsupported SSL request)
  20. does not comply with psr-4 autoloading standard. Skipping.
  21. MySQLのSTR_TO_DATE関数を使用するとnullが返却される問題