查看mysql用户列表 mysql> select user,host from mysql.user; +------+---------------+ | user | host | +------+---------------+ | abc | 192.168.182.% | | sync | 192.168.182.% | | root | localhost | +------+---------------+ 3 rows in set (0.01 sec)
查看对应的权限 mysql> show grants for 'abc'@'192.168.182.%'; +------------------------------------------------------------+ | Grants for abc@192.168.182.% | +------------------------------------------------------------+ | GRANT USAGE ON *.* TO 'abc'@'192.168.182.%' | | GRANT ALL PRIVILEGES ON `studb`.* TO 'abc'@'192.168.182.%' | +------------------------------------------------------------+ 2 rows in set (0.00 sec)
mysql>
当授权发现有错时,可以直接采取删除用户方法进行删除 mysql> delete from mysql.user where user='abc' and host='192.168.100.%';
或者可以用 revoke 进行回收权限 mysql> REVOKE all on studb.* from 'abc'@'192.168.182.%';
授权 mysql > grant all on 'studb'.* to 'abc'@'192.168.182.%' identified by 'Uplooking_123';
注意 刷新mysql > flush privileges;
测试某个用户是否可登陆或者是否某些权限: # mysql -uabc -pUplooking -h192.168.182.150 -----测试登陆