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

JS 4 super practical tips to improve development efficiency

Table of contents 1. Short circuit judgment 2. Op...

Markup Language - Phrase Elements

Click here to return to the 123WORDPRESS.COM HTML ...

How to use time as a judgment condition in MySQL

Background: During the development process, we of...

Nginx service 500: Internal Server Error one of the reasons

500 (Internal Server Error) The server encountere...

11 Examples of Advanced Usage of Input Elements in Web Forms

1. Cancel the dotted box when the button is press...

How to correctly modify the ROOT password in MySql8.0 and above versions

Deployment environment: Installation version red ...

Detailed tutorial on installing MySQL database on Alibaba Cloud Server

Table of contents Preface 1. Uninstall MySQL 2. I...

Linux bash: ./xxx: Unable to execute binary file error

Today I sent a small tool for Ubuntu to a custome...

Using react-virtualized to implement a long list of images with dynamic height

Table of contents Problems encountered during dev...