MySQL Account management Command usage instructions

Source: Internet
Author: User
Tags mysql view

MySQL to add new users can be done in two ways:

1. By way of the grant statement, we will explain this in the MySQL permissions below, which is simply an example.
2. Direct operation of the MySQL authorization form (this method is now basically not used)
Description: The more common approach is to use the GRANT statement to complete the increase of new users

Basic format:

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

1. Create Account

The code is as follows Copy Code
CREATE USER ' Jeffrey ' @ ' localhost ' identified by ' I pass ';


2, delete the account (delete the account will also delete all its permissions)

The code is as follows Copy Code

DROP USER ' Jeffrey ' @ ' localhost ';


3. Assigning Permissions

The code is as follows Copy Code

Grant all privileges on *.* to ' Jeffrey ' @ '% ' identified by ' password ' with GRANT OPTION


4, Recycling permissions

The code is as follows Copy Code

REVOKE INSERT on *.* from ' Jeffrey ' @ ' localhost ';
REVOKE all privileges, GRANT OPTION from ' Jeffrey ' @ ' localhost ';


5, the account name change

The code is as follows Copy Code

RENAME USER ' Jeffrey ' @ ' localhost ' to ' Jeff ' @ ' 127.0.0.1 ';


6, modify the password

The code is as follows Copy Code
SET PASSWORD = PASSWORD (' Mypass ');
SET PASSWORD for ' Jeffrey ' @ ' localhost ' = PASSWORD (' Mypass ');


How does MySQL view all of the added user information?

Basic format:

The code is as follows Copy Code

SELECT * from Mysql.user;

For example:

The code is as follows Copy Code

Mysql>select Host,user,password from Mysql.user; Car

Attention

MySQL user name is up to 16 characters in length. This limits the hard coding between the MySQL server and the client and prevents the password from being stolen by modifying the definition of the table in the MySQL database.

Note: You should never modify any of the tables in the MySQL database in any way, only the scripts provided for this purpose are run by the MySQL distribution secondary school. Redefining the MySQL system tables as otherwise would result in undefined (and unsupported!) Behavior.

The operating system username is completely unrelated to the MySQL username, or even the maximum length may be different. For example, the UNIX user name is limited to 8 characters

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.