2
votes

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 where status = 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.

Error Screenshot: enter image description here

2
can u run this command php artisan config:clear ?Jignesh Joisar
Yes but I have the same error message when I run php artisan config:clearDarek P
What do you get when you run ` $ mysql -u root --host=localhost --port=8889 newDB -p` and typed in root as the password? Have you created the newDB table and the root user with root password?D Malan
I prefer the unix socket provided by mamp's mysql installationkuh-chan
@DelenaMalan when I run your code I have "Enter password: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) " and yes this is new empty db with standard namp user credentials (user: root, pass: root) When I am connecting to db via browser localhost:8889 so everything is good and I can connectDarek P

2 Answers

2
votes

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

1
votes

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