新安装的MySQL5.7,登录时提示密码错误,安装的时候并没有更改密码,后来通过免密码登录的方式更改密码,输入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、my.ini 加入skip-grant-tables
2、重启MySQL,
3、输入 mysql 直接登录MySQL数据库,然后use mysql
3.1.mysql> use mysql;Database changed
3.2.给root用户设置新密码,蓝色部分自己输入:mysql>update MySQL.user set authentication_string=password('root') where user='root' ;Query
OK, 1 rows affected (0.04 sec)Rows matched: 1 Changed: 1 Warnings: 0
3.3.刷新数据库mysql> flush privileges;Query OK, 0 rows affected (0.01 sec)
3.4.退出mysql:mysql> quitBye
PS:root为新密码
4、编辑my.ini文件删掉skip-grant-tables 这一行,然后重启MySQL,
6、mysql -u root -p