遇到修改mysql用户命令不成功时,可通过下面命令进行检查,在mysql的安装路径执行命令:

1)安装mysqld
E:\mysql-8.0.12-winx64\bin>mysqld --initialize --console
E:\mysql-8.0.12-winx64\bin>mysqld --install

2)启动mysql服务
E:\mysql-8.0.12-winx64\bin>net start mysql

3)查看mysql服务是否存在
E:\mysql-8.0.12-winx64\bin>tasklist| findstr "mysql"

4)进入mysql数据库,输入原密码
E:\mysql-8.0.12-winx64\bin>mysql -u root -p
5)修改密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
Query OK, 0 rows affected (0.02 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec)

修改密码时的解释
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'; #更新一下用户的密码
FLUSH PRIVILEGES; #刷新权限

posted on 2020-01-17 17:27  知不可见  阅读(184)  评论(0编辑  收藏  举报