本文最后更新于 1047 天前,其中的信息可能已经有所发展或是发生改变。
修改Mysql密码
mysqladmin -u用户名 -p旧密码 password 新密码
ALTER USER 'root'@'localhost' IDENTIFIED BY '你的密码';
flush privileges;
mysql -u root -p
use mysql;
update user set password=password("newPassword") where user='root';
flush privileges;
quit;
常见错误
- client does not support authentication protocol requested by server
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'Awer133//';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%';
出现连接失败的原因:mysql8 之前的版本中加密规则是mysql_native_password,而在mysql8之后,加密规则是caching_sha2_password
把用户密码登录的加密规则还原成mysql_native_password这种加密方式
开放root远程访问权限
use mysql;
update user set host='%' where user='root';
select user,host from user where user = 'root';
创建用户 并且赋权
create user 'newuser'@'%' identified by 'password';
flush privileges;
grant all privileges on [databasename].* to 'newuser'@'%' with grant option;
show grants for 'newuser'@'%';
ALTER USER 'newuser'@'%' IDENTIFIED WITH mysql_native_password BY 'password';