Linux Learning Notes: Creating Users and authorizations

Source: Internet
Author: User

Grant is typically used to create users and authorizations

Syntax format

GRANT

Priv_type [(column_list)]

[, Priv_type [(column_list)] ...

On [object_type] Priv_level

To User_specification [, user_specification] ...

[REQUIRE {NONE | ssl_option [[and] ssl_option] ...}]

[With {GRANT OPTION | resource_option} ...]


Grant all on test.* to "TestUser1" @ "127.0.0.1" identified by "test";

Underline the place to explain

The location of all is a command that can be used, or it can be a select,update,delete, separated by commas when used;

The location of the test.* is the table of which library, which represents all the tables in the test database;

"TestUser1" @ "127.0.0.1" is the specified user and IP from

"Test" is the password for test

Any of the above is preceded by a preposition, memory may be a bit difficult, to practice more.

In addition, this command creates a user first and then authorizes the corresponding.


If the combination of the user and IP already exists, the password is changed, and if it does not exist, a new combination is created (in the MySQL database user table)

mysql> select user,password,host from mysql.user;+-----------+------------------------- ------------------+-------------+| user      | password                                    | host         |+-----------+-------------------------------------------+-------------+|  root      | *1981B3D87F8E4997E444AC2F469A74D5145EEB7X |  localhost   | |  root      |                                             | vmtest.js   | |  root      | *1981B3D87F8E4997E444AC2F469A74D5145EEB7X |  127.0.0.1   | |  root      |                                             | ::1          | |            |                                             |  localhost   | |            |       & nbsp;                                    |  vmtest.js   | |  root      | *1981B3D87F8E4997E444AC2F469A74D5145EEB7X |  192.168.5.% | |  coosh     | *94BDCEBE19083CE2A1F959FD02F964C7AF4CFC2X |  127.0.0.1   | |  testuser1 | *94bdcebe19083ce2a1f959fd02f964c7af4cfc2x | 127.0.0.1   | +-----------+-------------------------------------------+-------------+9 rows in set  (0.00  SEC) mysql> grant select,update on test.* to  "Coosh" @ "192.168.5.%"   identified by  "XXX";          query ok,  0 rows affected  (0.00 sec) mysql> select user,password,host from mysql.user;                                        +-----------+------------------------- ------------------+-------------+| user      | password                                    | host         |+-----------+-------------------------------------------+-------------+|  root      | *1981B3D87F8E4997E444AC2F469A74D5145EEB7X |  localhost   | |  root      |                                            | vmtest.js    | |  root      | *1981B3D87F8E4997E444AC2F469A74D5145EEB7X |  127.0.0.1   | |  root      |                                             | ::1          | |            |                                             | localhost   | |            |                                             |  vmtest.js   | |  root      | *1981B3D87F8E4997E444AC2F469A74D5145EEB7X |  192.168.5.% | |  coosh     | *94BDCEBE19083CE2A1F959FD02F964C7AF4CFC2X |  127.0.0.1   | |  testuser1 | *94bdcebe19083ce2a1f959fd02f964c7af4cfc2x | 127.0.0.1   | |  coosh     | *91A66B6C7D4FABDB9225374DC006BB98E6C6F0CX |  192.168.5.% |+-----------+-------------------------------------------+-------------+10 rows in set  (0.00 sec) 



Linux Learning Notes: Creating Users and authorizations

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.