-- mysql的用户表在 mysql.user 表中use mysql;-- username:用户名称-- %:是通配符指的是任意IP,这个位置也可以指定特定的ip,或者localhost代表本机才可以登录createuser'username'@'localhost' identified by 'password';
create user 'username'@'%' identified by 'password';
-- 查看新创建的用户
select * from user where user = 'username';
-- 查看权限
show grants for 'username'@'localhost';
授权
超级用户权限
-- grant:授权-- all privileges:所有的权限-- on *.*:在哪个数据库的那个表-- to username@localhost:对哪个用户的哪个主机-- with grant option:是不是将username用户自己本身的权限赋给其他账户grantallprivilegeson*.*to'username'@'localhost'withgrantoption;-- 立即生效
flush privileges;
Mysql8.0.20 创建用户并授权创建用户-- mysql的用户表在 mysql.user 表中use mysql;-- username:用户名称-- %:是通配符指的是任意IP,这个位置也可以指定特定的ip,或者localhost代表本机才可以登录create user 'username'@'localhost' identified by 'password';create user 'username'@'%' identified by 'password'; -- 查看