Two Methods for configuring MySQL access restrictions

Source: Internet
Author: User
The following articles mainly describe two methods for configuring MySQL access restrictions: Grant command authorization and set each user permission, the following describes the specific content of the article, hoping to help you in this regard. We mainly use these two methods to set users. Go to MySQL (the best combination with PHP)

The following articles mainly describe two methods for configuring MySQL access restrictions: Grant command authorization and set each user permission, the following describes the specific content of the article, hoping to help you in this regard. We mainly use these two methods to set users. Go to MySQL (the best combination with PHP)

The following articles mainly describe two methods for configuring MySQL access restrictions: Grant command authorization and set each user permission, the following describes the specific content of the article, hoping to help you in this regard.

We mainly use these two methods to set users.

Go to the execution directory of MySQL (the best combination with PHP) (usually c: MySQL (the best combination with PHP) in ). Enter the combination of mysql(and PHP )d-)))))))))))))))mysql MySQL (and PHP)-user = root MySQL (the best combination with PHP). Otherwise, you cannot add new users. Go to the MySQL (best combination with PHP)> prompt to perform the operation.

Suppose we want to create a super user with the username system and user password manager.

Method 1

Use the Grant command for authorization. The input code is as follows:

 
 
  1. MySQL (best combination with php)> grant all privileges on *. * TO system @ localhost identified by 'manager' with grant option;

Display: Query OK, 0 rows affected (0.38 sec)

Method 2

Set each permission of a user:

 
 
  1. MySQL (best combination with PHP)> insert into user VALUES ('localhost ','

    System ', PASSWORD ('manager'), 'y ', 'y', 'y ');

For MySQL 3.22.34 (the best combination with PHP), there are 14 "Y" in total. The corresponding permissions are as follows (sorted by field ):

Permission table column name explanation Scope

Select Select_priv the select permission table is required only when a table is actually retrieved.

Insert Insert_priv allows you to insert a new row into an existing table.

Update Update_priv allows you to use the new value to update the columns in the row of an existing table.

Delete Delete_priv allows you to delete row tables that meet the conditions.

Create Create_priv allows you to create new databases and table databases, tables, or indexes.

Drop Drop_priv discard (delete) existing database and table database or table

Reload Reload_priv allows you to tell the server to read the authorization table again. Server Management

Shutdown Shutdown_priv may be abused (by terminating the server and rejecting other user services) Server Management

Process Process_priv allows you to view the common text of the currently executed query, including setting or changing the password query server management.

File File_priv permission can be abused to read any readable files from the server to the database table server for file Access

Grant Grant_priv allows you to grant your own permissions to other user databases or tables.

References References_priv allows you to open and close the record file database or table

Index Index_priv allows you to create or discard (delete) index tables.

Alter Alter_priv allows you to change the table, which can be used to overturn the permission system table by renaming the table.

If you only have select, insert, update, and delete permissions when creating a user, you can only perform operations on the existing table of a database.

Next we can create the database we want to use. We can directly enter it. For example, we want to create a database named XinXiKu. The following code is available:

 
 
  1. MySQL (the best combination with PHP)> create database XinXiKu;

Display: Query OK, 1 row affected (0.00 sec)

The above content is an introduction to the MySQL access restriction setting method. I hope you will get some benefits.

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.