lukaisailovic's avatar

Laravel Access denied for user 'root'@'localhost' sometimes ?

I have a weird issue. I get Access denied for user 'root'@'localhost' whenever any query executes (I try to display it or whatever). The weird thing that got me confused is that it works normally for php artisan migrate and php artisan db:seed (I've manually checked the database, its all there and rows are present inside tables too). I've tried config:clear, cache:clear etc but nothing helps. Any idea what should I do ?

0 likes
4 replies
jlrdw's avatar

Do you have 2 installs of MySql, many times this is the problem.

lukaisailovic's avatar

@JLRDW - I don't think I do. dpkg --get-selections | grep mysql results in:

mysql-client-5.7                                install
mysql-client-core-5.7                           install
mysql-common                                    install
mysql-server                                    install
mysql-server-5.7                                install
mysql-server-core-5.7                           install
php-mysql                                       install
php7.2-mysql                                    install

I'm not sure if mysql-server andmysql-server-5.7 count as two different instances ?

Edit: I've just reinstalled mysql to check, and no its the same.

jlrdw's avatar

Are the db values coming from env file, can you show what you have, star the PW.

Snapey's avatar

its a problem I gave seen before where mysql is accessible from IP connection but not from sockets

I cant remember which way aound it is, but try changing the host from 127.0.0.1 to localhost or vice versa

Please or to participate in this conversation.