PhoeniX5's avatar

Laravel SQLSTATE[HY000] [1698] Access denied for user 'root'@'localhost' (1698)

When loging in to laravel app I keep getting this error :

"SQLSTATE[HY000] [1698] Access denied for user 'root'@'localhost' (SQL: select * from `users` where `username` = Admin limit 1)"

I am no trying to login with root but it keeps showing this error, here is my .env :

APP_NAME=gestion_magasin
APP_ENV=local
APP_KEY=base64:6o5/esvKCiBvWTN1q2nWqvNMa0m6zJe8lEwheglLctM=
APP_DEBUG=true
APP_URL=http://localhost

LOG_CHANNEL=stack

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=gestion_magasin
DB_USERNAME=user
DB_PASSWORD=password

BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
0 likes
15 replies
PhoeniX5's avatar
PhoeniX5
OP
Best Answer
Level 1

I solved this by running the folowing commands :

php artisan config:cache
php artisan config:clear
php artisan cache:clear
3 likes
munazzil's avatar

Keep below field as like it is,

   DB_USERNAME=root
   DB_PASSWORD=
ammadasif25's avatar

This is a very complicated and tiring problem that we face. So follow these steps to make it work perfectly:

Steps: 1. open terminal 2. mysql -u root -p (enter) 3. enter your password 4. use mysql; 5. select user, host, plugin from mysql.user; 6. update user set plugin='mysql_native_password' where user='root';

7. update user set Password='Password('my_password') where user='root';

                                    or

    update user set authentication_string=password('my_password') where user='root';

8. flush privileges;
7. exit;
8. service mysql restart
9 likes
Roger_Aguiar's avatar

Thank you very much my friend! Your solution was the one that solved my problem here! God bless you for your help! Thank you!

Said Omar's avatar

I have this problem and try all those solutions but it doesn't work SQLSTATE[HY000] [1698] Access denied for user 'root'@'localhost' (SQL: select * from information_schema.tables where table_schema = blog and table_name = migrations and table_type = 'BASE TABLE')

Sinnbeck's avatar

@Said Omar if none of these solutions work, then your problem most likely isn't the same. Create a new tread and perhaps link to this one, saying nothing here worked for you

wyckie's avatar

Step 1:

sudo mysql -u root -p

-then enter your sudo password if it’s asked. -It will also ask for mysql password.

Step 2:

USE mysql;

Step 3:

UPDATE user SET plugin='mysql_native_password' WHERE User='root';

Step 4. FLUSH PRIVILEGES;

Step 5. exit;

Step 6. $ service mysql restart

padmajanofficial's avatar

am facing same issue like 'Illuminate  \  Database  \  QueryException PHP 8.2.27 11.21.0 SQLSTATE[HY000] [1698] Access denied for user 'root'@'localhost' select * from sessions where id = xINMeXW3DRCYIUv8dLMXwz3L4O8XzLbpgz3uhHNW limit 1'.. any solutuons?

my .env like DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=admin_ DB_USERNAME=rootdfs5435 DB_PASSWORD=kQ8wd6^27

padmajanofficial's avatar

problem solved, i reinstall laravel using plesk panel (using laravel toolkit provided by plesk), then replace default laravel files with my current files, then clear all type caches, set correct env credentials, all problem solved!!!

Please or to participate in this conversation.