增加MySQL使用者

來源:互聯網
上載者:User

  格式:grant select on 資料庫.* to 使用者名稱@登入主機 identified by "密碼"

例1、增加一個使用者user_britepic密碼為bkjia,讓他可以在任何主機上登入,並對所有資料庫有查詢、插入、修改、刪除的許可權。首先用以root使用者連入MySQL,然後鍵入以下命令:

  mysql> grant select,insert,update,delete on *.* to user_britepic@"%" Identified by "bkjia";

例1增加的使用者是十分危險的,如果知道了user_britepic的密碼,那麼他就可以在網上的任何一台電腦上登入你的MySQL資料庫並對你的資料為所欲為了,解決辦法見例2。

  例2、增加一個使用者user_avnads密碼為bkjia,讓此使用者只可以在localhost上登入,並可以對資料庫aaa進行查詢、插入、修改、刪除的操作(localhost指本地主機,即MySQL資料庫所在的那台主機),這樣使用者即使用知道user_avnads的密碼,他也無法從網上直接存取資料庫,只能通過MYSQL主機來操作aaa庫。

  mysql>grant select,insert,update,delete on aaa.* to user_avnads@localhost identified by "bkjia";

  用新增的使用者如果登入不了MySQL,在登入時用如下命令:

  mysql -u user_britepic -p -h 192.168.113.50 (-h後跟的是要登入主機的ip地址)

相關文章

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.