安装mysql遇到ERROR 1054 (42S22)和 ERROR 1045

deer332025-05-28技术文章36

ERROR 1054 (42S22): Unknown column 'password' in 'field list'

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

1054是因为原来是mysql数据库下已经没有password这个字段了,password字段改成了

authentication_string

解决办法都是vim /etc/my.cnf 加入skip-grant-tables

保存文档并退出:

#:wq

然后重启mysql,不输入密码进入mysql

mysql> use mysql;

mysql> update user set password=password("你的新密码") where user="root";

mysql> flush privileges;

mysql> quit

重新回到my.cnf,去掉刚才添加的内容,然后重启MySQL。