Summary of setting permissions for MySQL database users

Source: Internet
Author: User

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

For example, add a user user1 password for password1, so that it can be logged on the computer, and all databases have query, insert, modify, delete permissions


My MySQL is installed in C:/mysql

First, change the password

The first way:
1. Change before root without password
C:/mysql/bin>mysqladmin-u root password "Your password"
2, change before the root has a password, if the case is 123456
C:/mysql/bin>mysqladmin-u root-p123456 Password "Your password"
Note: The changed password cannot be in single quotes, either with double quotes or without quotes

The second way:

1, c:/mysql/bin>mysql-uroot-p password to log in as root
2, mysql>use mysql Select database
3, Mysql>update user set Password=password (' Your password ') where user= ' root ';
4, Mysqlflush privileges; Reload Permission Table

Second, the user rights set

1. Log in as root (also available to other authorized users)
2, the following create a test user, the password is test, and can only operate on the picture Database command
Mysql>grant all on picture.* to test identified by "test";

The syntax of the GRANT statement looks like this:
Grant privileges (columns) on what to user identified by ' password ' with Grant OPTION


If you think the above command method to increase the MySQL database user permissions more cumbersome, we can directly use phpMyAdmin to authorize OH.

phpMyAdmin's homepage is shown in the following illustration:

Second, create a user (how you have created a good user before, you can omit this step)

After you click the permissions shown in the previous illustration, you can see the following image:

Click on the "Add new user" connection to add a new database username

As shown in the following illustration:

Third, permission settings

As shown in the following illustration:

Edit Hellen permissions for this user

As shown in the following illustration:

Adding users can also fill in the user's permissions, you can also add users to edit the user's permissions later

These permissions are described in detail below:

1. Data section

SELECT: Means to allow reading of data

Insert: Refers to allowing data to be inserted and replaced

UPDATE: Means to allow change of data

Delete: refers to allowing data to be deleted

File: Refers to allowing data to be imported from data, and allowing data to be exported to a file

2. Structural part

Cteate: Allow creation of new databases and tables

Alter: Allow modifying the structure of an existing table

Index: Allow creation and deletion of indexes

Drop: Allow database and tables to be deleted

Create temporary tables: Allow temporary tables to be created

CREATE VIEW: Allow new views to be created

Show VIEW: Allow query attempts

Create routine: Allow new stored procedures to be created

Alter routine: Allow modification of stored procedures

Execute: Allow query execution

Management and resource limitations This is not explained in detail here, it is generally the administrator root account all the permissions, the above is the ordinary user rights.

Iv. Reload Authorization Table

After modifying user rights, you need to go back to phpMyAdmin's homepage and reload the authorization

As shown in the following illustration:

As long as you understand the user's permissions settings, I believe that your database management operations will be handy

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.