MySQL creates new users and databases and authorizes

Source: Internet
Author: User

Test environment: Centos 6.3 and MySQL 5.3

First, the new user

Log in to MySQL
@>mysql-u root-p
@> Password
Create user
mysql> INSERT INTO Mysql.user (Host,user,password) VALUES ("localhost", "Cplusplus", Password ("cplusplus.me"));
Refresh System Permissions Table
Mysql>flush privileges;
This creates a user named: cplusplus Password: cplusplus.me.

Second, the login test

mysql>exit;
@>mysql-u cplusplus-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 (CPLUSPLUSDB)
Mysql>create database Cplusplusdb;
Authorizes the Cplusplus user to have all the permissions of the CPLUSPLUSDB database.
>grant all privileges in cplusplusdb.* to [e-mail protected] identified by ' cplusplus.me ';
Refresh System Permissions Table
Mysql>flush privileges;
Mysql> Other operations

Iv. Partial delegation of authority

Mysql>grant select,update on cplusplusdb.* to [e-mail protected] identified by ' cplusplus.me ';
Refreshes the System permissions table.
Mysql>flush privileges;

V. Delete users

@>mysql-u root-p
@> Password
Mysql>delete from user WHERE user= "cplusplus" and host= "localhost";
Mysql>flush privileges;

Vi. Deleting a database

Mysql>drop database Cplusplusdb;

Seven, change the password

@>mysql-u root-p
@> Password
Mysql>update Mysql.user Set Password=password (' New password ') where user= "Cplusplus" and host= "localhost";
Mysql>flush privileges;

Original link: http://www.cplusplus.me/1778.html

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.