Home  >  Article  >  Database  >  Summary of MySQL permission control statements

Summary of MySQL permission control statements

藏色散人
藏色散人forward
2020-03-23 08:54:492034browse

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;

2. Switch to mysql Database instance:

use mysql;

3. View the user table:

select host, user, password from user;

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';

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

drop user 'yang'@'localhost';

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

create user 'yang'@'%' identified by 'yangpass';

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');

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'@"%";

9. Refresh permissions to make permission modifications effective:

flush privileges;

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

create user 'remote'@'%' identifed by 'app';

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';

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

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

Recommended mysql video tutorial, address: //m.sbmmt.com/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!

Statement:
This article is reproduced at:cnblogs.com. If there is any infringement, please contact admin@php.cn delete