Table of contents
2. Database user authorization
Allow users to remotely connect to MySQL on a specified terminal and have specified permissions
Summary of authorized user rights
1. Database user management
Create new user
Command: create user 'username'@'source address' identified by 'password';
Query users in database
Instruction: use mysql;
select user,authentication_string,host from user;
Rename username
Command: rename user 'username'@'source address' to 'new username'@'source address';
delete users
Command: drop user 'username'@'source address';
Modify current user password
Command: set password=password('password');
Change other user's password
Command: set password for 'username'@'localhost'=password('password');
2. Database user authorization
Authorize
The Grant statement is specially used to set the access permissions of database users. When the specified user name does not exist, the Grant statement will create a new user. When the specified user name exists, the Grant statement is used to modify the user information. The status list is divided into For Select (query), update (modify), and insert (insert) permissions, use ALL to represent all permissions
Command: grant [permission] on [database name].[table name] to 'username'@'localhost' identified by 'password';
Only give query permission, and then log in to test whether there are other permissions.
Command: quit to exit
mysql -u username -p password
use lfh;
select * from lfh;
update lfh set a=10 where e=400;
Allow users to remotely connect to MySQL on a specified terminal and have specified permissions
Command: grant [permission] privileges on [database].[table name] to 'username'@'source address' identified by 'password';
show grants for 'username'@'source address'; #View the specified corresponding permissions
revoke permission
The Usage permission can only be used for database login and cannot perform any operations. The Usage permission cannot be revoked.
Command: revoke [permission] on [database name].[table name] from 'username'@'source address';
Summary of authorized user rights
insert #insert
select #query
update #modify
delete #Delete field content
drop #Delete libraries and tables
create #Create libraries and tables
index #Create index
alter #Change table attributes
create view #Create view
create routine #Create stored procedure
alter routine #Modify stored procedure
event #event
trigger on #Create desolver