4

I tried deploying my project to an AWS EC2 server but when I tried to run php artisan migrate I am getting the following error.

PDOException::("SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: NO)")

PDO::__construct("mysql:host=127.0.0.1;port=3306;dbname=myDb", "root", "", [])

The following is my .env file:

PP_NAME="MyProject"
APP_ENV=local
APP_KEY=base64:UTBgGqkc11OYbnGGJVe32xFluhFeNw288oH0UcmMYqU=
APP_DEBUG=true
APP_URL=http://localhost

LOG_CHANNEL=stack

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=myDb
DB_USERNAME=root
DB_PASSWORD=
9
  • try composer dump-autoload and then php artisan migrate
    – tempra
    Commented Sep 14, 2019 at 21:09
  • @JGEscarilla still the same, i edited the error message, not sure if it helps
    – I. Antonov
    Commented Sep 14, 2019 at 21:11
  • does your AWS EC2 server has a password? I think it has.
    – tempra
    Commented Sep 14, 2019 at 21:16
  • no, but my mysql's root user has one, i tried using that password in DB_PASSWORD. I also tried using secret.
    – I. Antonov
    Commented Sep 14, 2019 at 21:21
  • 1
    you must put that password. that is why it prompts using password: NO because it is looking for the password.
    – tempra
    Commented Sep 14, 2019 at 21:24

1 Answer 1

1

Okay, so I got it fixed. All I did was run php artisan config:clear. The problem was I had a previous migration already done with wrong credentials and everything. So after running php artisan config:clear I went ahead and ran php artisan migrate and everything was fine.

Thanks all for your time.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.