初次登录MySQL修改密码是出现Unknown column 'password' in 'field list'的解决方法

新安装的MySQL5.7,登陆时提示密码错误,安装的时候并无更改密码,后来经过免密码登陆的方式更改密码,输入update mysql.user  set password=password('root') where user='root'时提示ERROR 1054 (42S22): Unknown column 'password' in 'field list',原来是mysql数据库下已经没有password这个字段了,password字段改为了mysql

authentication_stringsql

因此更改语句替换为update MySQL.user set authentication_string=password('root') where user='root' ;便可数据库

完整的更改MySQL密码的方式以下:vim

一、vim /etc/my.cnf 加入skip-grant-tables.net

二、重启MySQL, /etc/init.d/mysqld restartrest

三、终端输入 mysql 直接登陆MySQL数据库,而后use mysqlip

四、update mysql.user set authentication_string=password('root') where user='root' ;get

mysql5.7更改密码应该采用命令ALTER USER 'root'@'localhost'IDENTIFIED BY '********'其中密码的命名规则有所改变,详见string

五、编辑my.cnf文件删掉skip-grant-tables 这一行,而后重启MySQL,/etc/init.d/mysqld restart,不然MySQL仍能免密码登陆it

六、mysql -u root - 而后输入密码便可登陆MySQL数据库

相关文章
相关标签/搜索