標籤:nts int 許可權 nbsp sele 複製 cal 使用 後退
grant all on *.* to ‘user1‘ identified by ‘passwd‘
grant SELECT,UPDATE,INSERT ON db1.* to ‘user2‘@‘192.168.133.1‘ identified by ‘passwd‘;
grant all on db1.* to ‘user3‘@‘%‘ identified by ‘passwd‘;
show grants;
show grants for [email protected];
1.grant all on *.* to ‘user1‘@127.0.0.1‘ identified by ‘123456‘;
授權給user1這個使用者所有的許可權,
127.0.0.1,是來源ip;是指只能通過這個ip來串連這個mysql
*.* 這個*是庫名
然後退出mysql,使用如下命令登入:
mysql -uuser1 -p123456 -h127.0.0.1 #即可登入
可將 改成localhost,則不需要指定 ip登入,如下:
grant all on *.* to ‘user1‘@localhost‘ identified by ‘123456‘; #則登入的時候直接 mysql -uuser1 -p123456 可以直接登入
grant SELECT,UPDATE,INSERT on db1.* to ‘user2‘@‘192.168.133.1‘ identified by ‘passwd‘;
grant SELECT,UPDATE,INSERT on db1.* to ‘user2‘@‘192.168.133.1‘ identified by ‘passwd‘;
show grants\G;
show grants for [email protected]‘192.168.133.1‘;
有一種情況會用到,我給192.168.133.1ip授權,發現不夠,還要在192.168.133.2上給再授權,則可以這樣操作:
show grants for [email protected]‘192.168.133.1‘;
然後複製列表中的兩句,注意,兩組都需要複製,因為是一組的;
然後再show grants for [email protected]‘192.168.133.2;‘ 則可以發現多了一個和1 一樣的兩段。
mysql--使用者管理