#进入mysql
mysql -uroot -p
#授权:
GRANT ALL ON *.* TO 'root'@'%';
#刷新权限:
flush privileges;
#更新加密规则:
ALTER USER 'root'@'localhost' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER;
#更新root用户密码:
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';
#刷新权限:
flush privileges;
#查看表
show tables;
#查看用户
select * from user;
举例:
1.创建数据库 bbin
create database bbin;
2.给数据库创建单独用户 bbin;
create user bbin;
3.给用户 bbin 设置密码为 abc###123
set password for bbin="abc###123";
4.给用户 bbin 赋予数据库 bbin 所有权限,并允许远程连接
GRANT ALL ON bbin.* TO 'bbin'@'%';