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

User section of commands commonly used in mysql

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

Share

Shulou(Shulou.com)06/01 Report--

New user:

Create user user name;-- create an empty password user.

Create user username IDENTIFIED BY 'password';-- create a password when you create a new user.

Grant select [, insert...] On mysql.user to username identified by 'password';-while creating a new user, grant the user permission to user table in select mysql database.

Update password:

1. Set password=password ('password');-- modify the current user password.

2. Set password for user name = password ('password');-- modify the specified user password.

3. Update mysql.user set password=password ('password') where user=' username'- modify it directly with update

Flush privilegs;-updates memory to make it work

View user permissions:

Use mysql

Select * from user where User='test'\ G;-- format the permissions of the test user.

Delete a user:

Delete from user where user='';-delete the column with empty user name in the user table and add from. Prevent task users from being able to log in freely

Flush privileges;-flush the memory to make the changes take effect

Authorize the user:

Grant all on mysql.user to test@'%';-gives all users named test all permissions for the user table of the mysql database.

Grant all on stu.* to test2@'%';-Grant all test2 users access to the stu database

Query user permissions:

Select * from mysql.user where user=' any user name';-- query the user's permissions at the database level

Show grants;-query current user permissions

Show grants for user name;-- query the permissions of the specified user

Change the permissions:

Revoke all privileges on mysql.user from test;-reclaims all permissions of the test user on the mysql.user data table.

Revoke select on mysql.user from test2;-reclaims test2's select permissions on mysql.user data tables.

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