MySQL create user and authorize

Source: Internet
Author: User
Tags mysql create mysql create user root access

1. Create a new user.


//log in to MySQL
@>mysql-u root-p
@> Password
//Create user
mysql> INSERT INTO Mysql.user (Host,user,password) VALUES ("localhost", "abc", Password ("1234"));
//Refresh System Permissions Table
Mysql>flush privileges;
This creates a user named: The ABC password is: 1234.

then log in.

mysql>exit;
@>mysql-u abc-p
@> Enter Password
mysql> Login Successful

2. Authorize the user.

//log in to MySQL (with root access). I am logged in as root.
@>mysql-u root-p
@> Password
//First create a database for the user (test2)
mysql>create database test2;
//Authorize the ABC user to have all permissions for the Test2 database. (and all IP can be logged in, note: my.cnf to comment point bindress=127.0.0.1)
>grant all privileges in test2.* to ' abc ' @ ' percent ' identified by ' 1234 ';
//Refresh System Permissions Table
Mysql>flush privileges;
mysql> Other Operations

/*
If you want to specify partial permissions to a user, you can write:
mysql>grant select,update on test2.* to ' abc ' @ ' percent ' identified by ' 1234 ';
//Refresh the System permissions table.
Mysql>flush privileges;
*/

3. Delete the user.
@>mysql-u root-p
@> Password
mysql>delete from user WHERE user= "abc" and host= "localhost";
Mysql>flush privileges;
//Delete a user's database
mysql>drop database test2;

4. Modify the specified user password.
@>mysql-u root-p
@> Password
mysql>update Mysql.user Set Password=password (' New password ') where user= "abc" and host= "localhost";

Mysql>flush privileges;


Recommendation: Welcome to Exchange, put forward some guidance and suggestions

MySQL create user and authorize

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.