I have a problem with my Laravel project. After cloning the repo from git I did
npm install
composer install
php artisan migrate
I have an error:
In Connection.php line 664:
SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) (SQL: select * from
languages
wherestatus
= 1)In Connector.php line 70:
SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES)
I've added few changes to .env
file only
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:q/o7QZeznstW1iBW65t8F7usVPI1oA9osHGaCa6uONU=
APP_DEBUG=true
APP_URL=localhost
LOG_CHANNEL=stack
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=8889
DB_DATABASE=newDB
DB_USERNAME=root
DB_PASSWORD=root
I am using mamp on mac os for my web environment.
Open the .env
file and edit it.
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:q/o7QZeznstW1iBW65t8F7usVPI1oA9osHGaCa6uONU=
APP_DEBUG=true
APP_URL=http://localhost
LOG_CHANNEL=stack
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE= // Your Database Name
DB_USERNAME= // Yout Database Username
DB_PASSWORD= // Your Database Password
NOTE: If no password is set on the database, clear it DB_PASSWORD
This error basically comes from the after changes in the .env file:
SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES)
After completion of .env
edit, must be clear cache: php artisan config:cache
Try adding this to your .env
file
DB_SOCKET=/Applications/MAMP/tmp/mysql/mysql.sock
I use MAMP too and always need this inside my .env
files