2

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

5
  • can u run this command php artisan config:clear ? Commented Mar 15, 2019 at 10:49
  • Yes but I have the same error message when I run php artisan config:clear Commented Mar 15, 2019 at 10:50
  • 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? Commented Mar 15, 2019 at 10:57
  • I prefer the unix socket provided by mamp's mysql installation Commented Mar 15, 2019 at 11:13
  • @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 connect Commented Mar 15, 2019 at 11:18

2 Answers 2

2

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

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks :) I add your code to .env but still not working :(
Make sure you clear your cache after to be sure. Try leaving the password blank to when using root to see if that works
Hi, thanks. I run ' php artisan config:cache ' every time when I update .env
1

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

2 Comments

I had these fields filled with my mamp db information (Check printscreen). Still not working. I have this error when I type all php artisan command :(
Hello @DarekP The solution to the error is my answer, if you still have an error then Sorry I'm not familiar with Mac OS

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.