新建用户
root用户登陆,新建用户mysql> create user istester identified by "isTester@321"; Query OK, 0 rows affected (0.07 sec)查询用户是否创建成功mysql> select user,host from mysql.user; +---------------+-----------+ | user | host | +---------------+-----------+ | istester | % | | liuqin | % | | mysql.session | localhost | | mysql.sys | localhost | | root | localhost | +---------------+-----------+重置用户密码update mysql.user set authentication_string=PASSWORD('Liuqin@321') where user='liuqin';查看用户的所有权限mysql> show grants for istester; +--------------------------------------+ | Grants for istester@% | +--------------------------------------+ | GRANT USAGE ON *.* TO 'istester'@'%' | +--------------------------------------+
此时用户istester只能本地或远程登陆
用户授权
tip:
用户权限主要用处:可以限制用户访问哪些库、哪些表可以限制用户对哪些表执行SELECT、CREATE、DELETE、DELETE、ALTER等操作可以限制用户登录的IP或域名可以限制用户自己的权限是否可以授权给别的用户授权
格式:grant 权限 on 数据库对象 to 用户@'%(localhost)' identified by "passwd"授权查询、插入、更新、删除数据库中所有表数据grant select on idoxu.* to istester@'%' identified