-1

I am working with laravel 7 and after clone my existing repo which was created via windows operating system and right now i am using macOS. After cloning I copy .env.example and converted into .env file and then run the below commands,

  1. composer install
  2. npm install && npm run dev
  3. php artisan key:generate

All of the above commands run perfectly and then i run the 4 number commands to seed the database.

  1. php artisan migrate:fresh --seed

After run the php artisan migrate:fresh --seed, I have faced an error [1045] Access denied for user 'root'@'localhost' (using password: NO) (SQL: SHOW FULL TABLES WHERE table_type = 'BASE TABLE')

Then I checked the php version and it showed php version: 8 and that's why I downgrade the php version from version 8 to 7.4 and right now the requires version are given below,

  • PHP Version: 7.4.30
  • Composer Version: 2.4.1

then I clone again and run the same commands 1,2,3 and 4 but iot's sorrow that I have faced same error again. Please check the attached file and check the error and help me to solve the error.

migrate related issues in laravel 71

Nico Haase
  • 11,420
  • 35
  • 43
  • 69
Imdadul Haque
  • 1,635
  • 5
  • 23
  • 44

2 Answers2

2

That indicates a problem with your database connection. Your Laravel application is not able to connect to the MySQL database. Check that mysql is running and that you have the correct database name, port, user, and password for your mysql client, or try connecting to mysql outside of the application.

Once you have completed the preceding steps and are able to connect to MySQL from outside of the application, you can run:

php artisan optimize:clear
php artisan cache:clear
php artisan config:cache
php artisan migrate:fresh --seed
0

There maybe 2 problems with your database connection.

Try to write correct database username and password at your .env file, in case you have created manually,

OR

If you are working on existing database, then try to create new user for your my sql database, Open your mysql database go to privileges, add new user for your database and set password, then rewrite the username and password at .env file.

myql db

Wasib Hussain
  • 166
  • 1
  • 8