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,
composer install
npm install && npm run dev
php artisan key:generate
All of the above commands run perfectly and then i run the 4 number commands to seed the database.
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.
2
Answers
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:
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.