This article uses examples to describe the management of MySQL users and permissions. Share with you for your reference, the details are as follows:
The data exchange between users and database servers is divided into two stages: (1) Do you have the right to connect? (2) Do you have the right to perform this operation? 1. Do you have the right to connect? How does the server determine whether the user has the right to connect? in accordance with: 1) Where are you from? host These three information of users are stored in the user table in the MySQL database. Modify the host domain so that the IP can connect mysql>update user set host='192.168.137.123' where user = 'root'; mysql>flush privileges; -- flush privileges Change User Password mysql>update user set password=password('11111111') where xxx; mysql>flush privileges; -- flush privileges 2. Do you have the right to perform this operation?
When a user logs in, the user table can first restrict user logins, and secondly, it also saves the user's global permissions. If the user does not have any permissions, the db table will be used to check whether the user has permission to operate a certain database. If neither of them exists, the table_priv table will be used to check whether the user has permission to operate a certain table. If yes, the user can operate the table according to the existing permissions. 1) Global authorization and revocation Global authorization format: grant [permission 1, permission 2, permission 3] on *.* to user@'host' identified by 'password' Common permissions: all, create, drop, select, insert, delete, update Authorization: Create user lisi, set the host to 192.168.191.%, and the % wildcard indicates that any host ending with 192.168.191.xxx can connect. The password is 12345678. grant all on *.* to lisi@'192.168.191.%' identified by '12345678'; Reclaim permissions: revoke all on *.* from lisi@'192.168.191.%'; 2) Database-level authorization and revocation
Authorization: grant all on mysqlmaster.* to lisi@'192.168.191.%' identified by '12345678'; Take Back: revoke all on mysqlmaster.* from lisi@'192.168.191.%'; 3) Table-level authorization and revocation
Authorization: grant insert,update,select on mysqlmaster.goods to lisi@'192.168.191.%' identified by '12345678'; Take Back: revoke insert,update,select on mysqlmaster.goods from lisi@'192.168.191.%'; Readers who are interested in more MySQL-related content can check out the following topics on this site: "MySQL query skills", "MySQL transaction operation skills", "MySQL stored procedure skills", "MySQL database lock related skills summary" and "MySQL common function summary" I hope this article will be helpful to everyone's MySQL database design. You may also be interested in:
|
<<: Node.js uses express-fileupload middleware to upload files
>>: How to use nginx to access local static resources on Linux server
Table of contents 1. What is DOM 2. Select elemen...
This article example shares the specific code of ...
Preface Using Docker and VS Code can optimize the...
I have previously shared the usage of asynchronou...
Table of contents 1. Panorama II. Background 1. R...
I remember when I was interviewing for my current...
Effect: CSS style: <style type="text/css&...
1. Introduction MDL lock in MYSQL has always been...
Introduction: Compared with traditional image ver...
This article uses examples to illustrate the prin...
routing vue-router4 keeps most of the API unchang...
As a powerful editor with rich options, Vim is lo...
The scroll bar position is retained when scrollin...
Specific method: (Recommended tutorial: MySQL dat...
Preface When docker run creates and runs a contai...