Discussion on MySQL user and rights management

Source: Internet
Author: User

▲mysql Users

MySQL database has only one root user by default

MySQL database saves user information in the MySQL database's UESR data sheet

▲mysql User Management

#创建一个新的用户

CREATE user username identified by ' password ';

Note: A new user cannot log in after creation because no permissions are set

#重命名一个用户

RENAME user name to new user name;

#删除一个用户

DROP user username;

#修改当前用户的密码

SET PASSWORD = PASSWORD (' password ');

Note: The password can be encrypted using password (' password ')

#修改指定用户密码

SET PASSWORD for User name = PASSWORD (' password ');

▲mysql Permission System

The MySQL privilege system can check if the user is able to connect, and can check if the user has permission to perform the action

The level of permission that MySQL grants can be divided into: global level, database level, surface level, column level, sub-program level

MySQL grants permissions through grant, revoking permissions through revoke

▲mysql Authorization Command

#授予一个用户权限

GRANT all privileges the on level to user name @ host identified by ' password ';

For example: Grant all privileges the stock.* to ' wddoer ' @ '% ' identified by ' password '; grant the user wddoer all permissions on the stock database

#撤销一个用户权限

REVOKE all privileges from user name;

#MySQL连接认证

When connecting to the MySQL service, MySQL verifies that the connection is allowed by the three points of username, password and host information.

Host:% for all hosts, localhost for native, 192.168.0.1 or www.wddoer.com for exact IP address or hostname, * for wildcard, 192.168.0.1/192.168.0.100 to designate a network segment

Note: The root user can only connect locally from the host by default

Discussion on MySQL user and rights management

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.