1、先在mysql.ini中增加2行配置
[mysqld]
skip-name-resolve
skip-grant-tables
2、重启mysql服务
3、mysql/bin 目录下输入cmd打开命令行 执行mysql -u root -p,提示输入密码,直接回车
4、命令行输入下面代码修改密码
grant all privileges on . to root@‘localhost’ identified by ‘123’;
5、会提示已配置跳过验证;
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
6、刷新权限权限重新修改密码即可。
flush privileges;

查询密码,查询结果是加密的!
show grants for username@localhost;

创建用户
create user ‘sa’@‘localhost’ identified by ‘123’;
授予用户权限:
grant all privileges on . to ‘sa’@‘localhost’
说明:
‘privileges’是你想要授予的权限,可以是ALL PRIVILEGES(所有权限)、SELECT(查询权限)、INSERT(插入权限)等。‘database.table’是你想要授权的数据库和表名,如果你想授予所有数据库和表的权限,可以使用通配符’.’。

例如,授予"myuser"用户对所有数据库和表的查询和插入权限,可以使用以下语句:

GRANT SELECT, INSERT ON . TO ‘myuser’@‘%’;