mysql的用户管理
1.Environment
mysql 8.0.21
2.Symptoms
1)服务器查看用户状态
root@mysqldb 16:13: [(none)]> select host,user,password_expired,password_last_changed,password_lifetime,account_locked,Password_reuse_history,Password_reuse_time,Password_require_current from mysql.user;
+---------------+------------------+------------------+-----------------------+-------------------+----------------+------------------------+---------------------+--------------------------+
| host | user | password_expired | password_last_changed | password_lifetime | account_locked | Password_reuse_history | Password_reuse_time | Password_require_current |
+---------------+------------------+------------------+-----------------------+-------------------+----------------+------------------------+---------------------+--------------------------+
| xx.xxx.5.11 | dbamonitor | N | 2021-07-13 15:51:03 | NULL | N | NULL | NULL | NULL |
| xx.xxx.5.12 | dbamonitor | N | 2021-07-13 15:51:21 | NULL | N | NULL | NULL | NULL |
+---------------+------------------+------------------+-----------------------+-------------------+----------------+------------------------+---------------------+--------------------------+
11 rows in set (0.00 sec)
2)客户端使用该用户可以登录,执行sql时提示需要重置密码。
[root@host ~]# mysql -udbamonitor -pXXXXXX -hXX.XXX.2.106 -P3306
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1370100
Server version: 8.0.21
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql>
mysql>
3.Changes
无
4.Cause
虽然从mysql.user中password_lifetime的标记为null,显示用户密码没有过期,没有被锁,但是查看确实是提示需要重置密码;
后来发现当password_lifetime的标记为null时,使用默认有效期,为default_password_lifetime参数控制为90。
root@mysqldb 16:22: [(none)]> show variables like '%default_password_lifetime%';
+---------------------------+-------+
| Variable_name | Value |
+---------------------------+-------+
| default_password_lifetime | 90 |
+---------------------------+-------+
5.Solution
设置为永不过期
alter user dbamonitor@'xx.xxx.5.11' identified by 'XXXXX' password expire never ;
6.再次测试,客户端就可以正常登陆查询了。
root@mysqldb 16:26: [(none)]> select host,user,password_expired,password_last_changed,password_lifetime,account_locked,Password_reuse_history,Password_reuse_time,Password_require_current from mysql.user;
+---------------+------------------+------------------+-----------------------+-------------------+----------------+------------------------+---------------------+--------------------------+
| host | user | password_expired | password_last_changed | password_lifetime | account_locked | Password_reuse_history | Password_reuse_time | Password_require_current |
+---------------+------------------+------------------+-----------------------+-------------------+----------------+------------------------+---------------------+--------------------------+
| xx.xxx.5.11 | dbamonitor | N | 2021-10-11 16:26:18 | 0 | N | NULL | NULL | NULL |
| xx.xxx.5.12 | dbamonitor | N | 2021-10-11 16:24:43 | 0 | N | NULL | NULL | NULL |
+---------------+------------------+------------------+-----------------------+-------------------+----------------+------------------------+---------------------+--------------------------+
11 rows in set (0.00 sec)
参考:
https://blog.csdn.net/weixin_34952098/article/details/114341002
原文地址:https://www.cnblogs.com/annez/p/15394096.html
- Date, TimeZone, MongoDB, java中date的时区问题
- spring boot 添加拦截器
- spring boot 部署为jar
- 重定向Http status code 303 和 302
- centos7查看系统版本,查看机器位数x86-64
- 在centos7中添加一个新用户,并授权
- 如何优化coding
- 在PowerShell中使用curl(Invoke-WebRequest)
- linux centos中添加删除修改环境变量,设置java环境变量
- CentOS7下安装mysql5.6修改字符集为utf8并开放端口允许远程访问
- CentOS7下mysql5.6修改默认编码
- 在idea中maven项目jdk编译version总是跳到1.5
- 命令行打印文件树列表: tree
- JavaScript 获取鼠标及元素在页面上的位置
- MySQL 教程
- MySQL 安装
- MySQL 管理与配置
- MySQL PHP 语法
- MySQL 连接
- MySQL 创建数据库
- MySQL 删除数据库
- MySQL 选择数据库
- MySQL 数据类型
- MySQL 创建数据表
- MySQL 删除数据表
- MySQL 插入数据
- MySQL 查询数据
- MySQL where 子句
- MySQL UPDATE 查询
- MySQL DELETE 语句
- MySQL LIKE 子句
- mysql order by
- Mysql Join的使用
- MySQL NULL 值处理
- MySQL 正则表达式
- MySQL 事务
- MySQL ALTER命令
- MySQL 索引
- MySQL 临时表
- MySQL 复制表
- 查看MySQL 元数据
- MySQL 序列 AUTO_INCREMENT
- MySQL 处理重复数据
- MySQL 及 SQL 注入
- MySQL 导出数据
- MySQL 导入数据
- MYSQL 函数大全
- MySQL Group By 实例讲解
- MySQL Max()函数实例讲解
- mysql count函数实例
- MYSQL UNION和UNION ALL实例
- MySQL IN 用法
- MySQL between and 实例讲解
- (火狐)Selenium WebDriver测试 NotADirectoryError: [WinError 267] 目录名称无效。
- 浅析Android高斯模糊实现方案
- Android 自定义验证码输入框的实例代码(支持粘贴连续性)
- _countof和sizeof
- Flutter适配深色模式的方法(DarkMode)
- RecyclerView+SnapHelper实现无限循环筛选控件
- 详解Android 8.1.0 Service 中 弹出 Dialog的方法
- 短信收发类无错版JustinIO.cs
- Android快速实现无预览拍照功能
- RecyclerView+PagerSnapHelper实现抖音首页翻页的Viewpager效果
- android中使用react-native设置应用启动页过程详解
- 面试官问我单例模式真的安全吗?我懵逼了
- 详解Android使用CoordinatorLayout+AppBarLayout实现拉伸顶部图片功能
- Android自定义控制条效果
- Android使用MediaPlayer和TextureView实现视频无缝切换