MySQL5.7更改密码

来源:互联网 发布:帝国cms 帐号被锁 编辑:程序博客网 时间:2024/06/04 11:39

MySQL5.7更改密码 ERROR: Unknown column ‘password’ in ‘field list’

新安装的MySQL5.7,登录时提示密码错误,安装的时候并没有初始化密码,后来通过免密码登录的方式更改密码。
输入:

update mysql.user  set password=password('123456') 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

3、 终端输入:

mysql -u root -p

密码为空

4、
方法一:

use mysql;update user set authentication_string=password('123456') where user='root' ;flush privileges;

方法二:mysql5.7更改密码应该采用命令

ALTER USER 'root'@'localhost'IDENTIFIEDBY '********';

5、编辑my.cnf文件删掉skip-grant-tables 这一行,然后重启MySQL,/etc/init.d/mysqld restart,否则MySQL仍能免密码登录.

0 0
原创粉丝点击