MySQL creates users and authorizes and revokes user permissions Operating environment: MySQL 5.0 1. Create a User Order: CREATE USER 'username'@'host' IDENTIFIED BY 'password'; Description: username - the username you will create, host - specifies the host on which the user can log in. If it is a local user, you can use localhost. If you want the user to log in from any remote host, you can use a wildcard. Password - the login password of the user. The password can be empty. If it is empty, the user can log in to the MySQL server without a password. example: CREATE USER 'dog'@'localhost' IDENTIFIED BY '123456'; CREATE USER 'pig'@'192.168.1.101_' IDENDIFIED BY '123456'; CREATE USER 'pig'@'%' IDENTIFIED BY '123456'; CREATE USER 'pig'@'%' IDENTIFIED BY ''; CREATE USER 'pig'@'%'; 2. Authorization Order: GRANT privileges ON databasename.tablename TO 'username'@'host'; Note: privileges - user's operation privileges, such as SELECT, INSERT, UPDATE, etc. (see the end of this article for a detailed list). If you want to grant all privileges, use ALL.; databasename - database name, tablename- table name. If you want to grant the user corresponding operation privileges for all databases and tables, you can use .. example: GRANT SELECT, INSERT ON test.user TO 'pig'@'%'; GRANT ALL ON .* TO 'pig'@'%'; Note: The user authorized by the above command cannot authorize other users. If you want to allow the user to authorize, use the following command: GRANT privileges ON databasename.tablename TO 'username'@'host' WITH GRANT OPTION; 3. Setting and changing user password Order: SET PASSWORD FOR 'username'@'host' = PASSWORD('newpassword'); If it is the current logged in user, use SET PASSWORD = PASSWORD("newpassword"); example: SET PASSWORD FOR 'pig'@'%' = PASSWORD("123456"); 4. Revoke User Permissions Order: REVOKE privilege ON databasename.tablename FROM 'username'@'host'; Note: privilege, databasename, tablename - Same as the authorization part. Example: REVOKE SELECT ON . FROM 'pig'@'%'; Note: If you grant authorization to user 'pig'@'%' like this (or something similar): GRANT SELECT ON test.user TO 'pig'@'%', then using the REVOKE SELECT ON . FROM 'pig'@'%'; command will not revoke the user's SELECT operation on the user table in the test database. On the contrary, if the authorization is GRANT SELECT ON . TO 'pig'@'%'; then Detailed information can be viewed using the command SHOW GRANTS FOR 'pig'@'%';. 5. Deleting Users Order: DROP USER 'username'@'host'; The above is what I introduced to you about MySQL: creating users, authorizing users, revoking user permissions, changing user passwords, and deleting users (practical skills). I hope it will be helpful to you. If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website! You may also be interested in:
|
<<: How to manage cached pages in Vue
>>: Detailed tutorial on compiling and installing python3.6 on linux
Concept of SFTP sftp is the abbreviation of Secur...
Linux change hostname command 1. If you only need...
Record lock locks a single index record. Record l...
Use HTML CSS and JavaScript to implement a simple...
MySQL replication table detailed explanation If w...
for loop Basic syntax format: for(initialize vari...
Preface For a long time, the application and lear...
The table structure is as follows: id varchar(32)...
Table of contents js calling method Android 1.js ...
Preface As a heavy user of front-end frameworks, ...
This article example shares the specific code of ...
Use native JS to write a nine-square grid to achi...
Table of contents Node connects to Mysql Install ...
question Recently I needed to log in to a private...
A Multi-Select is a UI element that lists all opt...