MySQL5.7更改密码

    xiaoxiao2021-03-25  64

    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仍能免密码登录.

    转载请注明原文地址: https://ju.6miu.com/read-39684.html

    最新回复(0)