DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=task
DB_USERNAME=root
DB_PASSWORD=******
所有数据库列表
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| nodeDB |
| performance_schema |
| phpmyadmin |
| pythonDB |
| sys |
| task |
+--------------------+
8 rows in set (0.13 sec)
已经尝试了这些解决方案
SQLSTATE[HY000] [1045] Access denied for user 'username'@'localhost' (using password: YES)
Access Denied for User 'root'@'localhost' (using password: YES) - No Privileges?
答案 0 :(得分:0)
如果您能够登录到mysql控制台。然后尝试通过以下命令打印Mysql用户。
SELECT user,authentication_string,plugin,host FROM mysql.user;
如果您发现root
的插件类型为auth_socket
,则您需要通过以下命令将其更改为mysql_native_password
。
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
不要忘记用您的密码替换password
。
然后使用FLUSH PRIVILEGES;
或者,您可以创建另一个用户并授予特权。
CREATE USER 'ankush'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'ankush'@'localhost' WITH GRANT OPTION;