MySQL create a user and processing the right to limit

table of Contents

1. Rights Management
1.1 pairs a new user additions and deletions to
1.2 pairs of the current user authorization management
1. Rights Management
we know that our highest authority administrator is the root user, it has the highest level operations. Including select, update, delete, update, grant and other operations. Then the general DBA engineers created after the company and a user password, let you to connect to the database operations, and to the current user to set a permission (or all privileges) operations. So then we need to take a brief look:

How to create a user and password
to the current user authorization
to remove the current user's permission
if you want to create a new user, you need the following:

1.1 pairs a new user additions and deletions to
1. Create a user:

Specify the ip: 192.118.1.1 of chao user login

create user 'chao'@'192.118.1.1' identified by '123';

Specify the ip:. 192.118.1 beginning of chao user login

create user 'chao'@'192.118.1.%' identified by '123';

Specify any user to log ip of chao

create user 'chao'@'%' identified by '123';

2. Delete the user
drop user 'username' @ 'IP address';

3. Modify the user
rename user 'username' @ 'IP address' to 'new user name' @ 'IP address';

4. Change password
set password for 'username' @ 'IP address' = Password ( 'new password');
1.2 pairs of current user authorization management

View Permissions

Syntax: show grants for username @IP
Show Grants for [email protected]; # view a user's permissions

Remote login

mysql -uroot -p123 -h 192.168.10.3

Authorization to account

Syntax: grant permission on the library name table name to the user name @IP.
Privileges: select (query) insert (insert) update (update) delete (delete) all (on behalf of all permissions)

All rights allocation

grant all on . to chao@'%';

Assign permissions to query

grant select on . to chao@'%';

Query and insert distribution rights

grant select,insert on . to chao@'%';

Refresh the authorization is effective immediately, related to permissions and user passwords are refreshed on the right

flush privileges;

Create an account and authorize

grant all on . to chao@'%' identified by '123' ;

Remove User Permissions

Syntax: revoke permissions on the library name table name from the user name @IP
REVOKE All on . From the Chao @ '%';

Guess you like

Origin blog.51cto.com/14551318/2440396