mysql使用者管理、常用sql語句、mysqlDatabase Backup恢複

來源:互聯網
上載者:User

標籤:常用sql   grant   預設   127.0.0.1   改ip   命令   指定   修改ip   情況下   

13.4 mysql使用者管理
  • 建立使用者並授權
[[email protected] ~]# mysql -uroot -p‘taoyuan‘  //登入mysql> grant all on *.* to ‘user1‘@‘172.0.0.1‘ identified by ‘123456‘;#建立user使用者並授予其所有許可權“*.*”(萬用字元)#第一個*表示db_name;第二個*表示tb_name#同時指定其來源IP127.0.0.1(即,只可通過此IP登入)#此處可以使用萬用字元%,代表所有IP(一般不使用)#identified by :設定密碼#quit 退出[[email protected] ~]# mysql -uuser1 -p123456 -h127.0.0.1

使用socket登入

#登入root使用者mysql> grant all on *.* to ‘user1‘@‘localhost‘ identified by ‘123456‘;Query OK, 0 rows affected (0.01 sec)#授權localhost#登入[[email protected] ~]# mysql -uuser1 -p123456

說明: 因為指定登入主機為localhost,所以該使用者預設使用(監聽)本地mysql.socket檔案,不需要指定IP即可登入。

  • 對具體許可權進行授權
[[email protected] ~]# mysql -urootmysql> show grants;#查看目前使用者的許可權mysql> show grants for [email protected]‘127.0.0.1‘;#查看指定使用者的許可權mysql> GRANT SELECT, INSERT, UPDATE ON `db1`.* TO ‘user2‘@‘192.168.1.15‘;                                                        Query OK, 0 rows affected (0.01 sec)#在不知道密碼的情況下,可以直接用show grants命令進行複製,修改ip地址 增加。

mysql使用者管理、常用sql語句、mysqlDatabase Backup恢複

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.