I found this error, how to fix and suggest me. thanks
waiphyo@acer:/var/www/html/comeback$ php artisan migrate
Illuminate\Database\QueryException : SQLSTATE[HY000] [1698] Access denied for user 'root'@'localhost' (SQL: select * from information_schema.tables where table_schema = laravel and table_name = migrations and table_type = 'BASE TABLE')
at /var/www/html/comeback/vendor/laravel/framework/src/Illuminate/Database/Connection.php:665
661| // If an exception occurs when attempting to run a query, we'll format the error
662| // message to include the bindings with SQL, which will make this exception a
663| // lot more helpful to the developer instead of just the database's errors.
664| catch (Exception $e) {
665| throw new QueryException(
666| $query, $this->prepareBindings($bindings), $e
667| );
668| }
669|
Exception trace:
1 PDOException::("SQLSTATE[HY000] [1698] Access denied for user 'root'@'localhost'")
/var/www/html/comeback/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:70
2 PDO::__construct("mysql:host=127.0.0.1;port=3306;dbname=laravel", "root", "", [])
/var/www/html/comeback/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:70
Please use the argument -v to see more details.
i guess u need to give a super user permission.
# Try this command
$ sudo php artisan migrate
If it's not working, did you set a password in MySQL?
If you set it, did you change set yojr database password in ".env" file?
./.env
...
DB_USER=your_username
DB_PASS=your_password
...
Nothing to do with .env file, it's a mysql issue, besides this line
PDO::__construct("mysql:host=127.0.0.1;port=3306;dbname=laravel", "root", "", [])
Shows what userid and password he is using. Try this
sudo mysql
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';
There is no need to run artisan commands from sudo. Ever.
Hi there,
Welcome to Laravel and we are glad to have you as part of the community.
Unfortunately this GitHub area is not a support area for general application issues. This is only for issues/bugs with the framework code itself.
I will be closing your ticket here. Instead please try asking your question on one of the many great community support areas that will likely give you a better answer more quickly:
If you feel I've closed this issue in error, please provide more information about how this is a framework issue, and I'll reopen the ticket.
Thanks in advance.
Thanks all for your suggestions.
Most helpful comment
Nothing to do with .env file, it's a mysql issue, besides this line
PDO::__construct("mysql:host=127.0.0.1;port=3306;dbname=laravel", "root", "", [])Shows what userid and password he is using. Try this