MYSQL 5.7 Add user, new database, user authorization, delete user, change password

Source: Internet
Author: User
Tags flush

1. New User
Create a test user with a password of 1234.

Mysql-u root-p
CREATE USER "Test" @ "localhost" identified by "1234"; #本地登录
CREATE USER "Test" @ "%" identified by "1234"; #远程登录
Quit
Mysql-utest-p #测试是否创建成功

2, for the user authorization

A. Authorization format: Grant permissions on the database. * To username @ Login host identified by "password";

B. Log in to MySQL and log in as root here:

Mysql-u root-p

C. Create a database for the user (TestDB):

Create Database TestDB;
Create DATABASE TestDB default charset UTF8 collate utf8_general_ci;

D. Authorize the test user to have all permissions for the TestDB database:

Grant all privileges the testdb.* to "test" @ "localhost" identified by "1234";
Flush privileges; #刷新系统权限表

E. Specify partial permissions to the user:

Grant Select,update on testdb.* to "test" @ "localhost" identified by "1234";
Flush privileges; #刷新系统权限表

F. Authorize the test user to have some permissions for all databases:

Grant Select,delete,update,create,drop [ email protected] "%" identified by "1234"; # "%" means authorization for all non-local hosts, excluding localhost

3. Delete users

Mysql-u root-p
Delete from Mysql.user Where user= "test" and host= "localhost";
Flush privileges;
Drop database TestDB;

Delete accounts and permissions:

Drop user username @ '% ';
Drop user username @ localhost;

4. Modify the specified user password

Mysql-u root-p
Update Mysql.user Set Authentication_string=password ("New password") where user= "test" and host= "localhost";
Flush privileges;

    

MYSQL 5.7 Add user, new database, user authorization, delete user, change password

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.