are you running any sort of virtualisation (eg homestead) where you might have more than one instance of mysql available to you?
have you changed anything in config/database.php ?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi, I've been following the Laracasts series and am trying to run php artisan migrate in the root directory of my laravel project and when i do i get the following error:
Illuminate\Database\QueryException : SQLSTATE[HY000] [1698] Access denied for user 'root'@'localhost' (SQL: select * from information_schema.tables where table_schema = blog and table_name = migrations)
at /home/david/Sites/blog/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664
660| // If an exception occurs when attempting to run a query, we'll format the error
661| // message to include the bindings with SQL, which will make this exception a
662| // lot more helpful to the developer instead of just the database's errors.
663| catch (Exception $e) {
> 664| throw new QueryException(
665| $query, $this->prepareBindings($bindings), $e
666| );
667| }
668|
Exception trace:
1 PDOException::("SQLSTATE[HY000] [1698] Access denied for user 'root'@'localhost'")
/home/david/Sites/blog/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:68
2 PDO::__construct("mysql:host=127.0.0.1;port=3306;dbname=blog", "root", "", [])
/home/david/Sites/blog/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:68
it seems pretty clear to me that the .env file doesn't contain the right information... but it does. here's my .env for mysql database:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=blog
DB_USERNAME=root
DB_PASSWORD=
Database I'm trying to enter is called blog, and the user name is root and the password is blank. That's how I access mysql on my machine... `sudo mysql -uroot -p' and it logs me right in.
Any idea what might be going wrong?
Ok the only thing that worked was deleting the root user and recreating it and flushing privileges as described here:
Please or to participate in this conversation.