mysql database user permission settings

Format:
. Grant permission to list on the name of the database table name to 'username' @ 'source address' identified by 'password';

* Permissions list: lists the various database operations authorized, divided by commas, such as: select, insert, update, etc., all permissions All expressed, can perform any operation.
* Library name table name: a database and name of the authorized operating table, you can use a wildcard (*) to represent all.
* Username @ Source Address: used to specify the user and allow access client address; the source address can be IP addresses, domain names,% wildcard to represent all. (But does not indicate localhost)

mysql wildcard:
* _: any single character 192.168.200._
* _: any character of any length 192.168.200%

案例:
MariaDB [(none)]> create database student;
Query OK, 1 row affected (0.01 sec)

MariaDB [(none)]> use student
Database changed
MariaDB [student]> create table users (user_name char(20) not null, user_passwd char(50),primary key (user_name));
Query OK, 0 rows affected (0.01 sec)

MariaDB [student]> insert into users values ('zhangsan',password('111111')),('lisi',password('222222'));
Query OK, 2 rows affected (0.01 sec)
Records: 2 Duplicates: 0 Warnings: 0

MariaDB [student]> select * from users;
+-----------+-------------------------------------------+
| user_name | user_passwd |
+-----------+-------------------------------------------+
| lisi | *A0C1808B1A47CECD5C161FEE647F5427F4EB6F98 |
| zhangsan | *FD571203974BA9AFE270FE62151AE967ECA5E0AA |
+-----------+-------------------------------------------+
2 rows in set (0.00 sec)

MariaDB [student]> grant select,insert on student.users to 'root'@'%' identified by '111222';
Query OK, 0 rows affected (0.00 sec)

MariaDB [student]> flush privileges; // refresh authorization form
Query OK, 0 rows affected (0.00 sec)

MariaDB [student]> exit
Bye

Guess you like

Origin www.cnblogs.com/lyqlyqlyq/p/11653240.html