Create a new mysql user, and give rights management

In slightly larger companies which are engaged in significant rights management. Especially the operation of the database important things this way, in case if you accidentally delete a library, is in trouble, it is generally a project will create a dedicated user to specify their rights can only control one database operations inside the company.

This would be a very reasonable project.

 

To create a new mysql user, then the user needs to operate at the root inside.

First landing mysql:

 

After landing can be used show databasesdatabases;

 I had wanted to explain in detail under the mysql user table, but it was straight to the point!

Use the command:

 create user`movie_user` @ `*` identified by'123456 ';
created a user named movie_user user password is 123456.

Back @ parameter is ip address can visit: The "%" can be landed at any ip,

Username @IP address of the user can only access this IP
 user name @ 192.168.1.% Can only be changed at the user to access the IP segment (% wildcard to represent any)
 username @% under the user can then access any IP (default IP address%)

Delete user, then use:

 drop user 'username' @ 'IP address';
so that you can delete out.

Modify a user:

 rename user 'username' @ 'IP address' to 'new user name' @ 'IP address';
Change Password:

 set password for 'username' @ 'IP address' = Password ( 'new password');
PS: user rights related data stored in the user table in the mysql database, so it can directly manipulate it (not recommended). Because the error-prone ah.

Users created only half completed, because the most important has not been given permission to post or you did not use its landing permission to operate table.

Here is the authorization to operate.

 1. Check the permissions

show grants for 'user' @ 'IP address'


2. Authorizes operation:

 

grant permissions on the database tables to 'user' @ 'IP address';.
 
// All rights except grant all privileges of
            select only check permissions
            select, insert the investigation and insert permission
            ...
            Usage No Access
            alter the Table Use alter
            alter routine Procedure alter procedure and using drop
            Create Table using Create
            Create Procedure routine use Create
            Create Temporary Tables Tables Temporary use Create
            Create User use create user, drop user, rename user All privileges and REVOKE
            Create View View using the Create
            delete use the delete
            drop using drop Table
            Execute using the call and the stored procedure
            file using select into outfile and Load Data INFILE
            grant Option use grant and REVOKE
            index using the index
            INSERT using INSERT
            Lock Tables using Lock Table
            Process using Show Full PROCESSLIST
            SELECT using SELECT
            Show Databases using Show Databases
            Show view view using the Show
            Update using the Update
            reload using flush
            Use mysqladmin shutdown shutdown (off the MySQL)
            Super ?? use change master, kill, logs, purge , master and set global. Also allows mysqladmin ???? debugging landing
            replication client server location access
            replication slave by the slave using copy
 
// database name. * All database
            database name. A table in the specified database tables of
            the database name. Specified database stored procedure the stored procedure
            . * * All database
delete permissions:

revoke privileges on database tables from 'user' @ 'IP address';
 

Published 51 original articles · won praise 9 · views 40000 +

Guess you like

Origin blog.csdn.net/weixin_39891030/article/details/89419832