Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Introduction to the permissions of MySQL database

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article introduces the relevant knowledge of "introduction to the permissions of MySQL database". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Introduction to MySQL permissions

Permissions, as the name implies, limit the scope of use of users according to level. User, db, tables_priv and columns_priv are used in MySQL to control permissions. The specific verification process is as follows:

Confirm the basic information: first determine whether there is Host (IP), User, Password of the lander from the user table, and verify if it exists; permission distribution: verify in sequence according to user, db, tables_priv and columns_priv. If the current level is passed, the next level of validation is not performed. For example, when the user permission verification is passed, the verification of the next three items is not performed.

Weighting operation

1. Start mysql in CMD:

Netstartmysql56

two。 Log in to mysql with root:

Mysql-uroot-ppwd

3. Create a user first without a user:

CreateuserxxxIDENTIFIEDby'pwd'; (pwd will be stored as a hash value)

To modify user information, please refer to the following examples:

Modify user name: renameuseroldusertonewuser; Delete user: dropuserusername; (you must delete the user's permissions before mysql5, but you don't need them after 5, delete them automatically.) Change the password: setpasswordforusername=password ('newpwd'); or: updatamysql.usersetpassword=password (' newpwd') whereuser='username'

4. View user permissions

Showgrantsforusername

5. Grant authority

Grantselectondb.*tousername

6. Reclaim permission

Revokeselectondb.*fromusername; (error will be reported if the permission does not exist)

You can grant multiple permissions at once, just add', 'between permissions, and so can recycling.

7. The permission takes effect immediately.

Flushprivileges

To sum up, the information that must be given when empowering is:

1. The authority to be granted; 2. The database or table to which access is granted; 3. User name.

8.grant and revoke can control access at several levels

1. The whole server: grantall/revokeall2. The whole database: ondatabase.*3. Specific table: ondatabase.table4. Specific column: grantselect (id,se,rank) ontestdb.apache_logtodba@localhost;5. Specific stored procedure: grantexecuteonproceduretestdb.pr_addto'dba'@'localhost'6. Specific function: grantexecuteonfunctiontestdb.fn_addto'dba'@'localhost'

This is the end of the introduction to the permissions of the MySQL database. Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report