mysql--使用者管理

來源:互聯網
上載者:User

標籤: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--使用者管理

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.