First, the new user
Log in to MYSQL
[Email protected]:~# mysql-uroot-p
Enter Password: password
Welcome to the MySQL Monitor. Commands End With; or \g.
Your MySQL Connection ID is 138
Server version:5.5.53-0ubuntu0.14.04.1 (Ubuntu)
Copyright (c), Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of the Oracle Corporation and/or its
Affiliates. Other names trademarks of their respective
Owners.
Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.
Create user
mysql> INSERT INTO Mysql.user (Host,user,password) VALUES ("localhost", "Zhouyuyao", Password ("Zhouyuyao123"));
mysql> INSERT INTO Mysql.user (Host,user,password) VALUES ("%", "Zhouyuyao", Password ("Zhouyuyao123"));
Refresh System Permissions Table
mysql> flush Privileges;
This creates a user named: Zhouyuyao Password: Zhouyuyao123.
Second, the login test
mysql>exit;
@>mysql-u zhouyuyao-p
@> Enter password
Mysql> Login Successful
Third, user authorization
Log in to MySQL
@>mysql-u root-p
@> Password
First create a database for the user (test)
Mysql>create database test;
Authorizing Zhouyuyao users to have all the permissions of the test database
Mysql> grant all privileges on test.* to [email protected] '% ' identified by ' Zhouyuyao123 ';
Refresh System Permissions Table
mysql> flush Privileges;
Mysql> Other operations
Iv. Partial delegation of authority
Mysql>grant select,update on test.* to [email protected]
Identified by ' cplusplus.me ';
Refresh System Permissions Table
mysql> flush Privileges;
V. Delete users
@>mysql-u root-p
@> Password
Mysql>delete from user WHERE user= "Zhouyuyao" and host= "localhost";
mysql> flush Privileges;
Vi. Deleting a database
Mysql>drop database test;
Seven, change the password
@>mysql-u root-p
@> Password
Mysql>update Mysql.user Set Password=password (' New password ') where
User= "Zhouyuyao" and host= "localhost";
mysql> flush Privileges;
MySQL creates new users and databases and authorizes