Mysql8.0创建用户

mysql 修改 root 的密码:

1
2
3
4
5
6
ALTER USER 'root'@'%' IDENTIFIED BY 'new_psd_123';



update user set host='%' where user='root';
alter user 'root'@'%' IDENTIFIED WITH mysql_native_password By '123456';
 1
 2
 3
 4
 5
 6
 7
 8
 9
10

# 8.0 版本之后的 修改权限语句

# 首先创建用户(需要指定密码加密方式为:mysql_native_password)
create user 'root'@'%' IDENTIFIED WITH mysql_native_password By '123456';
# 然后在修改权限
grant all privileges on *.* to 'root'@'%';

# 刷新权限
FLUSH PRIVILEGES;

ALTER USER ‘root’@’localhost’ IDENTIFIED WITH mysql_native_password BY ‘123456’;

ALTER USER ‘root’@’%’ IDENTIFIED WITH mysql_native_password BY ‘123456’;

ALTER USER ‘root’@’localhost’ IDENTIFIED WITH mysql_native_password BY ‘’;

ALTER USER ‘root’@’%’ IDENTIFIED WITH mysql_native_password BY ‘’;

问题报错 ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

问题解决: 修改密码

mysql> alter user ‘root’@‘localhost’ identified by ‘Root@123456’;

mysql>flush privileges;

更新即可

Licensed under CC BY-NC-SA 4.0
最后更新于 Jan 06, 2025 05:52 UTC
comments powered by Disqus
Built with Hugo
主题 StackJimmy 设计
Caret Up