How to create users and manage permissions in MySQL

How to create users and manage permissions in MySQL

1. How to create a user and password

1. Enter the mysql database

mysql> use mysql
Database changed

2. Add, delete, and modify new users

1. Create a user

# Specify the IP address: 192.118.1.1 as user chao to log in create user 'chao'@'192.118.1.1' identified by '123';
#Specify the IP address: 192.118.1. Chao user login create user 'chao'@'192.118.1.%' identified by '123';
# Specify any ip user chao to log in create user 'chao'@'%' identified by '123';

2. Delete User

drop user 'username'@'IP address';

3. Modify user

rename user 'username'@'IP address' to 'new username'@'IP address';

4. Change password

set password for 'user name'@'IP address'=Password('new password');

2. Authorize the current user

#View permissions show grants for 'user'@'IP address'

#Authorize user chao to query, insert, and update only the db1.t1 file grant select ,insert,update on db1.t1 to "chao"@'%';

#Authorize the Chao user to query only the db1 file grant select on db1.* to "chao"@'%';

# Indicates all permissions, except for the grant command, which is only available to root. User chao has any operation on the t1 file under db1. grant all privileges on db1.t1 to "chao"@'%';
#The chao user can perform any operation on the files in the db1 database. grant all privileges on db1.* to "chao"@'%';
#chao user has any operation on all files in the database grant all privileges on *.* to "chao"@'%';

3. Remove the current user's permissions

#Revoke permissions #Revoke any operation of user Chao on the t1 file of db1 revoke all on db1.t1 from 'chao'@"%"; 

# Revoke all permissions of the Chao user from the remote server on all tables in database db1 revoke all on db1.* from 'chao'@"%"; 

Revoke all privileges on *.* from 'chao'@'%';

The above is the details of how to create users and permission management in MySQL. For more information about creating users and permission management in MySQL, please pay attention to other related articles on 123WORDPRESS.COM!

You may also be interested in:
  • How to use DCL to manage users and control permissions in MySQL
  • Example analysis of mysql user rights management
  • Detailed explanation of MySQL user and permission management
  • In-depth explanation of MySQL user account management and permission management
  • Detailed explanation of MySQL user rights verification and management methods
  • Detailed explanation of MySQL user rights management
  • Summary of basic user and permission management methods in MySQL
  • Detailed explanation of MySQL user rights management

<<:  How to use the yum command

>>:  Detailed explanation of webpack-dev-server core concepts and cases

Recommend

MySQL sql_mode analysis and setting explanation

When inserting a set of data into the MySQL datab...

Example code for text origami effect using CSS3

Preface This article mainly shares with you an ex...

Docker Basic Tutorial: Detailed Explanation of Dockerfile Syntax

Preface Dockerfile is a script interpreted by the...

8 tips for Vue that you will learn after reading it

1. Always use :key in v-for Using the key attribu...

Summary and analysis of commonly used Docker commands and examples

Table of contents 1. Container lifecycle manageme...

Vue example code using transition component animation effect

Transition document address defines a background ...

Vue song progress bar sample code

Note that this is not a project created by vue-cl...

Tutorial on installing GreasyFork js script on mobile phone

Table of contents Preface 1. Iceraven Browser (Fi...

Example of integrating Kafka with Nginx

background nginx-kafka-module is a plug-in for ng...

Sample code for configuring nginx to support https

1. Introduction Are you still leaving your websit...

Detailed explanation of common usage of pseudo-classes before and after in CSS3

The before/after pseudo-class is equivalent to in...

Comparison of the efficiency of different methods of deleting files in Linux

Test the efficiency of deleting a large number of...

Detailed discussion of several methods for deduplicating JavaScript arrays

Table of contents 1. Set Deduplication 2. Double ...