MYSQL修改root密码
//登录命令
mysql -u root -p
//查看数据库命令
show databases;
use mysql;
//user表
show tables;
//查看所有用户
//host:用户登录的ip user:当前数据库的用户名
//authentication_string: 用户密码 (如果这行为空就是没有密码)
select host,user,authentication_string from user;
//先将密码置空 ''
update user set authentication_string ='' where user='root';
通过select 查询 出root 密码已经置空, 进行下一步操作;
ALTER user 'root'@'localhost' IDENTIFIED BY '你的新密码';
//mysql 新设置用户或更改密码后需用flush privileges刷新MySQL
//的系统权限相关表,否则会出现拒绝访问,
//或者直接重新启动mysql服务器,使新设置生效
FLUSH PRIVILEGES;
//退出后重新登录 发现密码已经修改
quit;
//登录命令
mysql -u root -p