Linux11.3 MySQL用户管理
创建用户
mysql> grant all on *.* to 'user1'@‘127.0.0.1’ identified by '123qwe'; Query OK, 0 rows affected (0.00 sec) 第一个*,表示库名,所有的库 第二个*,表示表,所有的表 @后面为该用户所登录的IP,%为所有IP identified by 后面为密码
针对具体的权限授权
grant SELECT,UPDATE,INSERT on db1.* to 'user2'@'192.168.133.1' identified by '123qwe';
如果授权一个用户的IP需要修改,可以在不知道其密码情况下修改
mysql> grant SELECT,INSERT on db1.* to 'user2'@'192.168.212.130' identified by '123qwe'; Query OK, 0 rows affected (0.00 sec) mysql> show grants for user2@'192.168.212.130'; +--------------------------------------------------------------------------------------------------------------------+ | Grants for user2@192.168.212.130 | +--------------------------------------------------------------------------------------------------------------------+ | GRANT USAGE ON *.* TO 'user2'@'192.168.212.130' IDENTIFIED BY PASSWORD '*050376F3855A67F5E2C6514FD3130B31006C1276' | | GRANT SELECT, INSERT ON `db1`.* TO 'user2'@'192.168.212.130' | +--------------------------------------------------------------------------------------------------------------------+ 2 rows in set (0.00 sec) mysql> GRANT USAGE ON *.* TO 'user2'@'192.168.212.130' IDENTIFIED BY PASSWORD '*050376F3855A67F5E2C6514FD3130B31006C1276'; Query OK, 0 rows affected (0.00 sec) mysql> GRANT SELECT, INSERT ON `db1`.* TO 'user2'@'192.168.212.131'; Query OK, 0 rows affected (0.00 sec)
查看用户权限
show grants; 默认ROOT用户 show grants for user2@192.168.133.1;