Analysis of MySQL user management operation examples

Analysis of MySQL user management operation examples

This article describes the MySQL user management operation. Share with you for your reference, the details are as follows:

In this article:

  • User introduction
  • View Users
  • Create a User Account
  • Modify Account
  • Deleting an Account
  • About Anonymous Users

Release date: 2018-04-19


User's introduction:

  • The mysql client connects to the server using the username.
  • The server can change the user's permissions, so each user has different permissions for the database or data table.
  • Generally speaking, you should not log in as the root user, because the root user has the highest permissions and can perform "dangerous" operations such as deleting the database. For security reasons, you should log in using another user and assign him appropriate permissions.
  • And the user should have a password. Using an anonymous user (without a password) is very dangerous. If this anonymous user is open to remote login, then others can log in to your MySQL as long as they detect that your port is open.

View users:

  • MySQL user accounts and information are stored in a MySQL database named mysql.
  • The mysql database has a table called user which contains all user accounts. The user table has a column called user, which stores the user login name.
    • image
  • When using select * from user\G to get complete table data
    • The suffix priv means permission, and N stands for none. image
    • host represents the host that is allowed to log in, and % allows local and non-local hosts to log in image
    • user is the user name image
    • The authentication string is a hash of the password. image

Create a user account:

  • Method 1: create user username@login address identified by 'password';
    • No login address means all addresses can log in image
    • If only local logins are allowed, this should be set to localhost image
  • Method 2: grant permissions on database.table to username@login address identified by 'password';
    • image
  • Method 3: You can use Insert to directly insert data into the user table, but it is not recommended.

Modify account:

  • Rename user: rename user original username@accessible address to new username@accessible address; [The accessible address of the original username is required, while the accessible address of the new username is optional, but if it is not filled in, it will default to % which means remote login is allowed]
  • Change password: set password for 'username'@accessible address = password('password'); [To change the password of the current user without specifying a username] [Accessible address is optional and must be the original accessible address]
    • imageimage
  • Modifying account permissions will be covered in another blog post. Hyperlink: MySQL user rights management

Deleting an Account:

  • drop user username;

Replenish:

  • Before MySQL 5.0, the drop user command only deletes the user but not the permissions. Before 5.0, you need to use revoke to delete the permissions first.

About anonymous user:

  • In the old version, there is an anonymous user by default, which allows you to log in to MySQL without using a user and password.
  • How to create an anonymous user image
  • Generally, anonymous users should not be created. Even if they are created for learning convenience, they should be set to local.

Readers who are interested in more MySQL-related content can check out the following topics on this site: "MySQL query skills", "MySQL transaction operation skills", "MySQL stored procedure skills", "MySQL database lock related skills summary" and "MySQL common function summary"

I hope this article will be helpful to everyone's MySQL database design.

You may also be interested in:
  • Detailed explanation of MySQL user rights management
  • Summary of basic user and permission management methods in MySQL
  • Sharing of user management methods under MySQL command line
  • Detailed explanation of MySQL user and permission management
  • Detailed explanation of MySQL user rights verification and management methods
  • PHP implements MySQL database connection operation and user management
  • Mysql 5.7.18 Using MySQL proxies_priv to implement similar user group management
  • MySQL User Management
  • In-depth explanation of MySQL user account management and permission management
  • Mysql database advanced usage of views, transactions, indexes, self-connections, user management example analysis
  • Example analysis of mysql user rights management
  • MySQL 8.0 user and role management principles and usage details

<<:  VUE + OPENLAYERS achieves real-time positioning function

>>:  Detailed explanation of Deepin using docker to install mysql database

Recommend

Tutorial on deploying the open source project Tcloud with Docker on CentOS8

1. Install Docker 1. I installed Centos7 in the v...

JavaScript web page entry-level development detailed explanation

Part 3: ❤Three ways to overlook backend data rece...

Native js realizes the drag and drop of the nine-square grid

Use native JS to write a nine-square grid to achi...

MySQL 8.0.18 deployment and installation tutorial under Windows 7

1. Preliminary preparation (windows7+mysql-8.0.18...

Solution to MySQL Chinese garbled characters problem

1. The Chinese garbled characters appear in MySQL...

Detailed explanation of js closure and garbage collection mechanism examples

Table of contents Preface text 1. Closure 1.1 Wha...

Vue Element-ui implements tree control node adding icon detailed explanation

Table of contents 1. Rendering 2. Bind data and a...

Solution to slow response of Tomcat server

1. Analytical thinking 1. Eliminate the machine&#...

Detailed example of jQuery's chain programming style

The implementation principle of chain programming...

Nginx restricts IP access to certain pages

1. To prohibit all IP addresses from accessing th...

Detailed explanation of the correct way to install opencv on ubuntu

This article describes how to install opencv with...

Beginners learn some HTML tags (3)

Related articles: Beginners learn some HTML tags ...

React's component collaborative use implementation

Table of contents Nesting Parent-child component ...