I am a quite experienced Laravel developer but this time I have an error which drives me crazy because all config files are correct.
I have a Mac with macOS Catalina (10.15.5), using Laravel 6, mySQL (mysql Ver 8.0.19 for osx10.15 on x86_64 (Homebrew)) and PHP 7.4.6.
In other Laravel projects I have no problem to connect to the database with the following credentials: 127.0.0.1
, 3306
, laravel
, root
, password
.
But on the current project I always get this error:
Access denied for user ''@'localhost' (using password: YES)
.
But I don't get why Laravel is using ''
as user and 'localhost'
as host. I have set the user to root
and the host to 127.0.0.1
in the .env
file. Do you guys have any explanation for that and how I can fix that?
.env
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:myprivatekey
APP_DEBUG=true
APP_URL=http://localhost
LOG_CHANNEL=stack
DB_CONNECTION=backend
DB_HOST_BACKEND=127.0.0.1
DB_PORT_BACKEND=3306
DB_DATABASE_BACKEND=radlvoo_backend
DB_USERNAME_BACKEND=root
DB_PASSWORD_BACKEND=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
MAIL_FROM_ADDRESS=null
MAIL_FROM_NAME="${APP_NAME}"
I already have run the following commands:
php artisan cache:clear
php artisan config:clear
Non of them are fixing the error. Also, before I had this error I had the error permission denied
when executing one of the commands above. I fixed that with this stack thread.
Maybe this is also helpful:
I have pushed the newest version of my project to my server. There I have to problem connecting to the database but I also had the same problem with the permission denied
error when executing cache:clear
or config:clear
. However, I have a shop.php
file under /config
which stores URLs where I fetch data from. When I run this command which is using the shop.php
config file to fetch the data it always is using the old shop.php
file with old URLs even though I have run cache:clear
and config:clear
multiple times!
I even have connected via FTP to check the shop.php
file but there are only the new URLs stored and not the old ones. I don't get what's the error here and if there is a connection between those errors!
Would appreciate any kind of help! Thanks!