Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access denied for user 'root'@'localhost' Laravel on ubuntu 18.04

I have a problem with laravel and mysql. It is possible for me to php artisan migrate and seed my database. But on the other side accessing to a page using the database is impossible for me. I receive the following error:

SQLSTATE[HY000][1698] Access denied for user 'root' @'localhost' (SQL: select * from `users`)

My .env is correctly filled in (I can migrate without worries)

My application runs under a ubuntu 18.04.

Does anyone have any idea where this might come from?

like image 435
rQwk Avatar asked Dec 14 '22 13:12

rQwk


1 Answers

The root user in mysql 5.7 now requires sudo. That means phpMyAdmin will not be able to use mysql -u root anymore instead use sudo mysql -u root credentials.

What you need to do is create a new user with the same privileges as the root credentials and use that instead.

Here's how you can do it.

like image 152
Kapitan Teemo Avatar answered Dec 17 '22 23:12

Kapitan Teemo