登录时提示密码错误,安装的时候并没有更改密码,后来通过免密码登录的方式更改密码,输入update mysql.user set password=password(‘root’) where user='root’时提示ERROR 1054 (42S22): Unknown column ‘password’ in ‘field list’,原来是mysql数据库下已经没有password这个字段了,password字段改成了
authentication_string
所以更改语句替换为update mysql.user set authentication_string=password(‘root’) where user=‘root’ ;即可
完整的更改MySQL密码的方式如下:
1、vim /etc/my.cnf 加入skip-grant-tables

2、重启MySQL, /etc/init.d/mysqld restart

3、终端输入 mysql 直接登录MySQL数据库,然后use mysql
4、update mysql.user set authentication_string=password(‘root’) where user=‘root’ ;
5、再次修改mysql登陆设置:
打开/etc/my.cnf
vim /etc/my.cnf
并删除之前往[mysqld] 里面添加的内容

这里写图片描述
6、再次启动mysql就可以正常使用啦!
这里写图片描述

mysql5.7更改密码应该采用命令
ALTER USER ‘root’@'localhost’IDENTIFIED BY '********'其中密码的命名规则有所改变,详见
http://blog.csdn.net/u010603691/article/details/50541979
5、编辑my.cnf文件删掉skip-grant-tables 这一行,然后重启MySQL,/etc/init.d/mysqld restart,否则MySQL仍能免密码登录
6、mysql -u root -p
然后输入密码即可登录MySQL数据库
本文详细介绍了在MySQL5.7中遇到密码错误时的解决步骤,包括免密码登录、更新users表中的authentication_string字段,以及如何通过修改my.cnf文件重启MySQL服务。

被折叠的 条评论
为什么被折叠?



