MySQL add user and User rights summary of various methods

Source: Internet
Author: User
Tags flush localhost mysql phpmyadmin

1. Grant statement

Format: Grant Select on database. * To User name @ login host identified by "password"

Description

(1) Grant all grants all permissions

(2) All tables in the Demo.* database demo

(3) NewUser user name

(4) @localhost MySQL server servers on the local computer

(5) Identfified by ' Password ' Set password

Add a user test1 password to ABC, so that he can log on any host, and all databases have query, insert, modify, delete permissions. First connect the root user to MySQL, and then type the following command:

The code is as follows Copy Code

Grant Select,insert,update,delete on *.* to test1@ "%" identified by "ABC";


Mysql>grant all privileges in *.* to monty@localhost identified by ' password ' with GRANT OPTION;
Mysql>grant Select,insert,update,delete,create,drop on *.* to custom@192.168.206.% IDENTIFIED by ' password ';

2. SQL statement

The code is as follows Copy Code

Mysql>insert into User (Host,user,password) VALUES (' 192.168.206.% ', ' High_vod ', password (' High_vod '));
Mysql>insert into DB VALUES (' 192.168.206.% ', ' High_vod ', ' high_vod ', ' y ', ' y ', ' y ', ' y ', ' y ', ' y ', ' N ', ' y ', ' y ', ' y-axis ', ' Y-axis ', ' Y ', ' y ', ' y ', ' y ', ' y ', ' y ', ' y ', ' y ');
Mysql>flush privileges;

Delete User

The code is as follows Copy Code

Use MySQL
Mysql>delete from user Where user= "xxxxx" and host= "localhost";
Mysql>flush privileges;

If you don't understand the order, we can use a simpler way to increase the user with phpMyAdmin ,

1, first we have to login phpMyAdmin.

2, create a database, the following figure, in the phpMyAdmin right window, fill in the database name, point creation can.

For example, here we create a database with the name: NetShield
Successful creation will have the following tips:

3, after the establishment of the database in the main interface of the right click "Permissions" to create a database account.

4, in the Permissions page, we click "Add New User"

5, in this page, we fill in the database to create the user name netshield.cn, the user's access scope, and password.

As pictured above, we have filled in the user name: netshield.cn, the database user only allows local access, host a selection of locally; password we can use automatically generated, the point below the "Generate" will generate a random password, and then point "Copy" will automatically fill in the Password box, You can also define a password yourself.
The system is more humane, it will be the default will check the prompt to grant the database "NetShield" all the permissions, which is exactly what we want.
The following global permissions box is not selected, directly pull to the bottom of the page execution can create a new user.
The database user is successfully created and returns the following page:

7, here, after the establishment of the user, you can then set up the user's database specific access rights.
If you need specific settings, continue to set up, do not need to be able to ignore. You can continue to do so if you need to set up a separate netshield.cn user's permissions later:

In the following diagram, select the NetShield we just created in the list of databases, which will automatically enter the permissions settings page for that database. If you want to give this user other library permissions, you can continue to set this, but remember, do not give the overall permissions of the whole, it is only the root.

In the permission settings of the following figure, we select all the permissions for the data, structure, and administrative permissions. Point execution.


Let me introduce you to the above permissions


Data:

SELECT: Allows reading of data.

Insert: Allows inserting and replacing data.

Updata: Allows data to be changed.

Delete: Allows data to be deleted.

File: Allows you to import data from a file and export the data to a file.

Structure:

Create: Allows creation of new databases and tables.

Alter: Allows you to modify the structure of an existing table.

Index: Allows indexes to be created and deleted.

Drop: Allows database and tables to be deleted.

Create temporary tables: Allows temporary tables to be created.

CREATE VIEW: Allows new comments to be created.

Show view: Displays the views created.

Create routine: Allows the creation of stored procedures.

Alter routine: Allows change and descent of stored procedures.

Execute: Allow execution of stored procedures.

Management:

Grant: Allows adding users and permissions, and does not allow reload of permission tables.

SUPER: Allows the connection to be made when the maximum allowable number is reached.

Process: Allows you to view the full query in the process list.

RELOAD: Allow reload of server settings and Refresh Server cache.

SHUTDOWN: Allow shutdown of server.

Show DATABASES: Allows access to the complete list of databases.

Lock tables: A table that allows the current thread to be locked.

REFERENCES: Not valid in this version of MySQL.

REPLICATION client: The user has the right to ask where the Affiliate/controller is.

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.