Level 6
If you are 100% that all your credentials are correct in your .env file... you can try running
php artisan config:clear
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello,
When I try to run 'php artisan migrate' for the first time, I get this error:
[Illuminate\Database\QueryException]
SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) (SQL: select * from information_schema.tables where table_schema = mydatabasenamehere
and table_name = migrations)
[PDOException]
SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES)
I tried restarting apache and clearing the config.
Here is my database.php and .env file:
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
],
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=mydatebasehere
DB_USERNAME=root
DB_PASSWORD=mypasswordhere
Hope you can help me with this.
Please or to participate in this conversation.