当前位置:网站首页>[MySQL from introduction to mastery] [advanced part] (III) creation of MySQL users_ Modification_ Delete and password settings
[MySQL from introduction to mastery] [advanced part] (III) creation of MySQL users_ Modification_ Delete and password settings
2022-06-28 12:45:00 【Man Nong Feige】
Hello! , I'm Manon Feige , Thank you for reading this article , Welcome to three links with one button .
1. Python Basic column , Basic knowledge in a net ,9.9 Yuan can't buy a loss , I can't buy it . Python From entry to mastery
️ 2. Python Crawler column , Systematically learn the knowledge points of reptiles .9.9 Yuan can't buy a loss , I can't buy it .python Reptile beginner level
️ 3. Ceph actual combat , Everything from principle to actual combat . Ceph actual combat
️ 4. Java Introduction to high concurrency programming , Punch in to learn Java High concurrency . Java Introduction to high concurrency programming
5. Take a stroll around the community , Weekly benefits , There are surprises every week . Manon Feige community , Leap plan
The whole network has the same name 【 Manon Feige 】 Welcome to your attention , personal VX: wei158556
List of articles
1. Key points
This article will first focus on MySQL How to create users in the database , Modify the user , Delete users and set passwords .
2. Environmental Science
| Environmental Science | edition |
|---|---|
| Red Hat | 4.8.5-39 |
| MySQL | 5.7 |
1. View all users
stay MySQL In the database , User information is stored in mysql Database user In the table , Just query the table to get all users
select host,user from user;

Here is to root Users to query , among host Represents the host :localhost Indicates that only local connections can be made ( Can't connect remotely ), and % You can connect both locally and remotely .user Represents the user's account .
3. Create user
stay MySQL In the database , The official recommendation CREATE USER Statement to create a new user , stay MySQL Version removed PASSWORD Encryption method , Therefore, direct use is not recommended INSERT Statement direct operation MySQL Medium user Table to add users .
Use CREATE USER Statement to create a new user , Must have CREATE USER jurisdiction . Every time you add a user ,CREATE USER The statement will be in the mysql Database user Add a record to the table , But the newly created account does not have any permissions , If the added account already exists ,CREATE USER Statement will return an error .
CREATE USER The basic syntax of a sentence is as follows :
CREATE USER user name [IDENTIFIED BY ' password '][, user name [IDENTIFIED BY ' password ']]
- The user name parameter indicates the account number of the new user , By the user (User) And the host name (Host) constitute , default Host yes %;
- “[]” Said the optional , in other words , You can specify that users need password authentication when logging in , You can also not specify password authentication , In this way, users can log in directly , however , This method of not specifying a password is not secure , It is not recommended to use . If you specify a password value , You need to use
IDENTIFIED BYSpecify the plaintext password value . - CREATE USER Statement can create multiple users at the same time .
give an example :
create user 'zhangsan' identified by 'Abc123456&';

The reason , The password setting is so complicated , Because MySQL The password verification rules set in the database are relatively strong . Otherwise, the following error will be reported :
mysql> create user 'zhangsan' identified by 'abcd1234';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
To view the password verification rules, you can execute the following statements :
SHOW VARIABLES LIKE 'validate_password%';

among ,
validate_password_number_count Specifies the length of the data in the password ,
validate_password_special_char_count Specifies the length of special characters in the password ,
validate_password_mixed_case_count Specifies the length of the uppercase and lowercase letters in the password .
validate_password_policy type
| policy | explain |
|---|---|
| 0 or LOW | Length( Only the length is limited ) |
| 1 or MEDIUM | Length; numeric, lowercase/uppercase, and special characters |
| 2 or STRONG | Length; numeric, lowercase/uppercase, and special characters; dictionary file |
| If , To set a simpler policy, execute the following command : |
set global validate_password_policy=LOW
4. Modify the user ( Rarely used )
It is seldom used to modify the user's functions , The modifying user here only modifies the user's account , It just needs to be modified user Just watch , The statement is simple update sentence . for example : Original
UPDATE user set user='li4' WHERE user='lisi';

5. Delete user
stay MySQL In the database , The official recommendation DROP USER Statement to delete a user , This statement will not only delete user User information in the table , There will be other settings , After executing the order , The deleted user will not be able to log in again MySQL. Use DROP USER You must have the permission of this command to delete users .
DROP USER The basic syntax of a sentence is as follows :
DROP USER user name [@ host ][, user name ].....
- The user name parameter indicates that you want to delete the user's account , By the user (User) And the host name (Host) constitute ;
- “[]” Said the optional ,
- DROP USER Statement can create multiple users at the same time , Delete multiple users separated by commas .
give an example :
DROP USER 'li4'@'localhost';

6. User password settings
6.1. Use ALTER USER Command to change the current user password :
Users can use ALTER Command to change your password , The following statement represents modifying the password of the current login user . The basic grammar is as follows :
ALTER USER USER() IDENTIFIED BY 'new_password';
Use ALTER Order to modify zhangsan User's password , Change the password to "abc1234A%", The order is as follows :
6.2. Use SET Statement to modify the current user password :
Use root The user login MySQL after , have access to SET Statement to change the password , Specifically SQL The statement is as follows :
SET PASSWORD='new_password';
This statement will automatically encrypt the password and then assign it to the current user .
Use SET Statement to modify zhangsan User's password , Change the password to "abc1234A%".
summary
This article introduces in detail in MySQL How to create users in , Delete the user and set the password .
边栏推荐
猜你喜欢

The Research Report of Analysys' 2022 China Banking privacy computing platform supplier strength matrix analysis' was officially launched

ASP. NET CORE Study02
![[unity Editor Extension practice], find all prefabrications through code](/img/0b/10fec4e4d67dfc65bd94f7f9d7dbe7.png)
[unity Editor Extension practice], find all prefabrications through code

ASP.NET CORE Study01

The white paper on the panorama of the digital economy and the digitalization of consumer finance were released

基础软件照搬开源不可取,自力更生才是正途

Why does CAD export PDF have no color

Hundreds of lines of code to implement a JSON parser
![[C language] use of nested secondary pointer of structure](/img/59/8b61805431e152995c250f6dd08e29.png)
[C language] use of nested secondary pointer of structure

Continuous integration practice of Baidu app based on pipeline as code
随机推荐
Unity导入资源后还手动修改资源的属性?这段代码可以给你节约很多时间:AssetPostprocessor
2022-06-28日报:LeCun最新论文:通往自主机器智能的道路
吐血推荐17个提升开发效率的“轮子”
centos6.5 php+mysql mysql库找不到
unity发布 webgl在手机端 inputfield唤醒键盘输入
几百行代码实现一个 JSON 解析器
EMC RS485接口EMC电路设计方案
Pyqt5 visual development
杰理之wif 干扰蓝牙【篇】
性能测试-01-简介
ASP. NET CORE Study08
Hundreds of lines of code to implement a JSON parser
最新!基于Open3D的点云处理入门与实战教程
JS duration and asynchronous function promise
命名空间和作用域
我的NVIDIA开发者之旅-Jetson Nano 2gb教你怎么训练模型(完整的模型训练套路)
Performance test-01-introduction
js 期约与异步函数 Promise
深入理解贝叶斯定理
IPETRONIK数据采集设备携手Softing Q-Vision软件致力于ADAS测试方案