Search code examples
phpsqllaravelxampp

XAMPP SQLSTATE[HY000] [1045]


When I try to load a page in my Laravel project which requires data from the SQL DB, the browser outputs the following error:

Illuminate\Database\QueryException
SQLSTATE[HY000] [1045] Access denied for user 'remotogl_web'@'localhost' (using password: YES) (SQL: select * from `issues`).

As well as the stack trace with the header:

Illuminate\Database\Connection::runQueryCallback
C:\Files\Work\Websites\remoto-web\vendor\laravel\framework\src\Illuminate\Database\Connection.php:692

I'm aware there are somewhat similar questions here, however:

  • I was working with the same database just minutes ago and didn't change anything. The problem appears to have come out of thin air.
  • I've tried removing the password from the database, removing the account from MySQL user accounts, and using 'root', reinstalling XAMPP, and resetting Windows.
  • The username and password being denied access do not match those in my .env file as I've changed that to:
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:pVZf8Hlgry16u1A4qf+CxsLrsQy3Z+dtVwXWhFKa3TA=
APP_DEBUG=true
APP_URL=http://localhost

LOG_CHANNEL=stack
LOG_LEVEL=debug

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=remotogl_remoto_web
DB_USERNAME=root
DB_PASSWORD=

#DB_USERNAME=root
#DB_PASSWORD=
BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120

MEMCACHED_HOST=127.0.0.1

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_MAILER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
MAIL_USERNAME=########
MAIL_PASSWORD=########
MAIL_ENCRYPTION=ssl
MAIL_FROM_ADDRESS=########
MAIL_FROM_NAME=Remoto

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}"

But it keeps denying access for 'remotogl_web'@'localhost' (using password: YES)


Solution

  • you have to update env file like this .

    DB_CONNECTION=mysql
    DB_HOST=127.0.0.1
    DB_PORT=3306
    DB_DATABASE=remotogl_remoto_web
    DB_USERNAME=remotogl_web
    DB_PASSWORD="Your Password"
    

    then run php artisan optimize

    i hope you got your solution .