Home > Database > Mysql Tutorial > Summary of MySQL permission control statements

Summary of MySQL permission control statements

藏色散人
Release: 2020-03-23 08:54:49
forward
2124 people have browsed it

Summary of MySQL permission control statements

MySQ permission control statement

1. Log in to the MySQL server using the root account:

mysql -u root -pmypass;
Copy after login

2. Switch to mysql Database instance:

use mysql;
Copy after login

3. View the user table:

select host, user, password from user;
Copy after login

4. Create a user "yang" that is only allowed to log in from the local machine, with a password of "yangpass":

create user 'yang'@'localhost' identified by 'yangpass';
Copy after login

5. Delete a local login user named "yang":

drop user 'yang'@'localhost';
Copy after login

6. Create a user "yang" that allows login from any host, with a password of "yangpass":

create user 'yang'@'%' identified by 'yangpass';
Copy after login

7. Change the password of user "yang" who is allowed to log in from any host. The new password is "yan":

set password for 'yang'@'%' = password('yan');
Copy after login

8. Change the password of user "yang" who is allowed to log in from any host. User, grant all permissions to the yang_test library:

grant all privileges on yang_test.* to 'yang'@"%";
Copy after login

9. Refresh permissions to make permission modifications effective:

flush privileges;
Copy after login

10. Create a user "remote" that allows login from any host, password For "app":

create user 'remote'@'%' identifed by 'app';
Copy after login

11. Grant CRUD permissions to the "t_weapon" table on the library "yang_test" to the "remote" user:

grant select, delete, update, insert on yang_test.t_weapon to 'remote';
Copy after login

12. Revoke user "yang" in " All permissions on the yang_test" library:

revoke all privileges on yang_test.* from 'yang'@'%';
Copy after login

Recommended mysql video tutorial, address: https://www.php.cn/course/list/51.html

The above is the detailed content of Summary of MySQL permission control statements. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:cnblogs.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template