更改数据库root账号密码
MySQL 5.7
update mysql.user set authentication_string=password('root') where user='root' ;
FLUSH PRIVILEGES;
user为用户名,password为设置的密码
说明
直接使用一下语句会报错
update mysql.user set password=password('root') where user='root
ERROR 1054 (42S22): Unknown column ‘password’ in ‘field list’,原来是mysql数据库下已经没有password这个字段了,
MySQL 8.0
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'wsxdcfvgbhn22@4';
FLUSH PRIVILEGES;