0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

LaravelでSQLSTATE[HY000] [1045] Access deniedになってmigrationができなかった話

Posted at

終わってみたら脱力するしか無かったので反省を兼ねて。

SQLSTATE[HY000] [1045] Access deniedでmigrationに失敗

$ php artisan migrate
(略)
SQLSTATE[HY000] [1045] Access denied for user '*******'@'localhost' (using password: YES) (Connection: mariadb, SQL: select exists (select 1 from information_schema.tables where table_schema = schema() and table_name = 'migrations' and table_type in ('BASE TABLE', 'SYSTEM VERSIONED')) as `exists`)

調査

.envに書いた内容でDBにアクセス可能、database.phpの内容も問題ない(そもそも触ってない)。
Webの情報は、大体が.envの内容が間違ってる、なんだけど....

原因

パスワードに # が含まれていて、それ以降がコメント扱いされていた。
ああ、そりゃそうだよなぁ。
確かに.envの内容が間違ってた。Webの情報は正しかった。

.env
DB_PASSWORD=foobar#hogehoge

解決

パスワードを " で囲った。
migrationも走った。

.env
DB_PASSWORD="foobar#hogehoge"

感想

内容は正しいのに!
書き方がダメだった!
反省。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?