mysql增加、刪除使用者、增加許可權

來源:互聯網
上載者:User

標籤:mysql

  • 建立使用者
     mysql>insert into mysql.user(Host,User,Password) values("localhost","test",password("1234"));     增加了一個使用者名稱為test、密碼為1234使用者,但該使用者只能在本地登陸,若想遠程登陸的話可將localhost改為%表示任何一台電腦都可以登陸,或改為特定的ip表示只能在特定的ip地址上登陸。
  • 為使用者添加許可權
     mysql>grant all privileges on testDB.* to [email protected] identified by ‘1234‘;     表示給使用者test在本地登陸時增加了對testDB資料庫的所有表的任何操作。若想指定許可權的話,可將all privileges修 改為select或update或delete或三者的組合;若想指定表的許可權,可以將testDB.*修改為testDB.info表示可對testDb資料庫中的info表進行操作;若想指定訪問的地址,可將@%修改為localhost表示使用者test只能在本地進行對資料庫的操作。
  • 重新整理系統許可權表
     mysql>flush privileges;
  • 刪除使用者
     mysql>Delete FROM user Where User=‘test‘ and Host=‘localhost‘;
  • 刪除賬戶及許可權
     mysql>drop user 使用者名稱@‘%‘;
  • 修改使用者密碼
     mysql>update mysql.user set password=password(‘新密碼‘) where User="test" and Host="localhost";

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.