在项目中连接mysql8.0出现 【1045 - Access denied for user 'root'@'localhost'(using password: YES)】报错
1.在cmd下启动mysql服务,确认账号密码是否正确(启动过程自行百度,论坛里一大堆)
net start mysql 注: 这个‘mysql’根据自己安装时定义的服务名称来写(比如我的服务名称是mysql8)
mysql P3307 -uroot -p123456 注:P后面是端口号,-u后面是用户名,-p后面是密码
若没什么问题,那就没问题
若密码错误mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
改密码,方法百度
2.第一步没问题之后初取确定为mysql远程访问权限不够
估计也是按照百度查的方式改了很多遍不起作用才找到这的吧
grant all on myDB.* to 'root'@'%' identified by '123456';
GRANT ALL PRIVILEGES ON *.* TO "root"@"%" IDENTIFIED BY "123456";
根据实际情况来用,不代表每个人都能成功
使用SQLyog登录,成功后找到工具--->用户管理---->主机设置为%---->保存
重新启动mysql服务
在项目中测试---------