0
votes

enter image description here.env file

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=task
DB_USERNAME=root
DB_PASSWORD=******

List of all databases mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | nodeDB | | performance_schema | | phpmyadmin | | pythonDB | | sys | | task | +--------------------+ 8 rows in set (0.13 sec)

Already tried these solutions

SQLSTATE[HY000] [1045] Access denied for user 'username'@'localhost' (using password: YES)

Access Denied for User 'root'@'localhost' (using password: YES) - No Privileges?

1
Have you created the Database task ? Also please check the username and password are correct and valid.Harish ST
yes, I. already create task database using cmd.Ankush Singh
Try getting into mysql with the username and password. mysql -u root -p and Enter Password. Check the credentials are actually valid.Harish ST
Do your password has special characters? Try changing the password with a simple one and check whether the issue is with the password.Harish ST
I am using ubuntu, I can enter using "sudo mysql" but fail to enter with "mysql -u root -p"Ankush Singh

1 Answers

0
votes

If you are able to login to mysql console. Then try printing the Mysql Users by the following commands.

SELECT user,authentication_string,plugin,host FROM mysql.user;

If you find root has a plugin of type auth_socket, then either you need to change it to mysql_native_password by the following command.

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';

Do not forget to replace the password with your password.

Then Flush Privileges by using FLUSH PRIVILEGES;

Alternatively, you can create another user and grant privileges.

CREATE USER 'ankush'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'ankush'@'localhost' WITH GRANT OPTION;