flush privileges;
create user '用户名'@'%' identified by '密码'; -- '%' 所有情况都能访问 -- 'localhost' 本机才能访问 -- '111.222.33.44' - 指定 ip 才能访问
update mysql.user set password = '新密码' where user = '用户名';
grant all privileges on `想授权的数据库`.`表名` to '用户名'@'%' identified by '密码'; -- all 可以替换为 select, delete, update, create, drop -- 举例: # 用户test密码java可对website库下的所有表执行所有权限 grant all privileges on `website`.* to 'test'@'%' identified by 'java'; grant insert, select, update on `test_db`.`test_tbl` to 'someone'@'localhost' identified by '123456';
update mysql.user set authentication_string = password("新密码") where user ='root' and host = 'localhost'
show grants for '用户名'@'主机';
delete from mysql.user Where user = '用户名';
select user, host from mysql.user;
create database `库名` default charset utf8mb4 collate utf8mb4_general_ci;
grant 权限列表 on 数据库名.数据表名 to '用户名'@'主机' identified by '密码' with grant option;
ps:如有错误,欢迎批评指正,谢谢!