Centos7--mysql 5.7 Adding users, deleting users, and authorizing

Source: Internet
Author: User

First, create a user : Log in to the database as root user creation

Command:

CREATE USER ' username '@'host'by'password';

For example:

CREATE USER ' Test_admin '@'localhost'by'[email protected]_s' ; CREATE USER ' test_admin2 '@'%'by';

Note

username--the user name that will be created;

host--specifies on which host the user can log on, "localhost" means that the user may log on locally only, cannot telnet on another machine, if you want to telnet, change "localhost" to "%", which means you can log on on any computer Or you can designate a machine to log in remotely;

password--The user's login password, the password can be empty, and if it is empty, the user can log on to the server without a password.

Ii. Authorization : Log in to the database as the root user for authorization

Command:

GRANT Privileges  on  to ' username '@'host'

Note

privileges--the user's operating rights, such as SELECT. Use all if all permissions are granted.

databasename--the database name. tablename--the table name. If you want to grant the user the appropriate operation permissions for all databases and tables, the * representation is available, for example, *. *

For example:

GRANT SELECT  on test_db. *  to ' test_admin2 '@'%'privilegesprivileges;

Third, revoke user rights

Command:

REVOKE  on  from ' username '@'host';

For example:

REVOKE SELECT  on test_db. *  from ' Test_min '@'%';

Iv. Deletion of accounts and privileges :

Command:

Drop User ' username '@'host';

V. viewing the user's authorization

Command:

 for ' username '@'host'

For example:

Mysql>SHOW GRANTS for 'Test_admin'@'%' ;+----------------------------------------------------------------+|Grants for[Email protected]%                                        |+----------------------------------------------------------------+| GRANTUSAGE on *.*  to 'Test_admin'@'%'                         || GRANT  All Privileges  on' test_manage_db '.*  to 'Test_admin'@'%' |+----------------------------------------------------------------+2Rowsinch Set(0.00sec) MySQL> 

  

Centos7--mysql 5.7 Adding users, deleting users, and authorizing

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.