CDbConnection failed to open the DB connection: SQLSTATE[28000] [1045] Access denied for user 'root'@'localhost' (using password: YES)

时间:2022-01-14 07:55:12

连接mysql出错:CDbConnection failed to open the DB connection: SQLSTATE[28000] [1045] Access denied for user 'root'@'localhost' (using password: YES)

注意这里的 'root'@'localhost' ,当检查登录用户和登录密码均没有错误的情况下,可以到 mysql.user 表中查看,User列中是否有 root用户;同时还要注意Host列,注意,这个字段是用来限制连接mysql的来源主机地址。

意思就是:如果你用localhost连接的就需要在这里配置localhost;如果你是用本机的内网地址[例如 192.168.100.100],也需要在这里配置。

最后再执行: mysql> flush privileges;

CDbConnection failed to open the DB connection: SQLSTATE[28000] [1045] Access denied for user 'root'@'localhost' (using password: YES)