MySQL creates new users and databases and authorizes

Source: Internet
Author: User


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

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.