Account management for MySQL

Source: Internet
Author: User

Account management in MySQL:

1 View all Users:
All user and permission information is stored in the user table in the MySQL database
View the structure of the user table
Desc user\g;

Main fields:
Host: Indicates which hosts are allowed to access
User: Indicates username
Authentication_string: Password after encryption
View All Users:
Select host,user,authentication_string from user;

2 Create an account and grant permissions:
Need to use account login after operation such as using root
Common permissions: Create alter drop INSERT UPDATE Delete select
Assign all permissions: All privileges

Create an account and grant permissions: Grant permission list on database to "user name" @ "Access host" identified by "password";

Example:
1 Login root:mysql-u Root-p
2 Grant all privileges to python.* "py" @ "%" identified by "123";
--All tables in the Python database have all permissions
--user name py,% means can use any IP login
--123 for password
3 Exit Root:quit;
4 Login Py:mysql-u Py-p

3 Authorization: Grant permissions on database to account 1, account 2 ... with GRANT option;


4 See what permissions a user has: Show grants for user name;

5 Back-up permissions: Log in with Root after operation
Revoke a user's permissions: The REVOKE permission list on the database name. * FROM "username" @ "host";

6 Change Password:
Method 1 do not log in, in Terminal: Mysqladmin-u User name-p password "New password"
Method 2 Use root login to modify the user table in the MySQL database
Use the password () function to encrypt the database
Refreshing permissions after modifying a database is only valid

In the root login state:
Change user table:
Update user Set authentication_string = password ("New password") where user = "username";
Refresh permissions:
Flush privileges;

7 Deleting an account:
Method 1 After using root login:
Drop user "username" @ "host";

Method 2 Delete the data in the user table of the MySQL library by using root login
Delete from user where user = "user name";
Permissions must be refreshed after operation: Flush privileges

It is recommended to use Method 1, if the host's letter capitalization, Method 1 will not be valid, and then use Method 2.



Account management for MySQL

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.