3.MYSQL之建立新使用者

來源:互聯網
上載者:User

標籤:main   rtu   user   使用者   and   clear   root   state   iat   

登入mysql伺服器後可使用grant命令來建立使用者並賦予相關許可權。

mysql> use mysql;Reading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -ADatabase changedmysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP    -> ON mysql    -> TO [email protected]localhost IDENTIFIED BY ‘password‘;Query OK, 0 rows affected, 1 warning (0.11 sec)

以上命令會在mysql資料庫中的user表建立一條使用者資訊記錄.分號(;)表示指令已完成編輯,準備好執行了。

這時可以通過以下命令來查看建立的使用者是否存在。

mysql> select user,host,authentication_string from user;+------------------+-----------+-------------------------------------------+| user             | host      | authentication_string                     |+------------------+-----------+-------------------------------------------+| root             | localhost | *74ED8DCE9B1B4B780E427473DDD66F8BE6398E8E || mysql.sys        | localhost | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE || debian-sys-maint | localhost | *0E2901479C3B89118B95A2622B7F895DFC60C4A0 || zara             | localhost | *08F7D6C84224646B57BDF66A6480F337F403F10C || firstuser        | localhost | *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 || rick             | localhost | *35EB40C575CD0DAA851919E0E3E28C0718879407 |+------------------+-----------+-------------------------------------------+6 rows in set (0.00 sec)

可見,新使用者已經存在,此時就可以以使用者進行登入了。

注意:在 MySQL5.7 中 user 表的 password項 已換成了authentication_string

mysql> \qByedeamon@deamon-H55M-S2:~$ mysql -u firstuser -pEnter password: Welcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 10Server version: 5.7.16-0ubuntu0.16.04.1 (Ubuntu)Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.mysql> 

 

3.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.