mysql 5.7 登录时报:ERROR 1862 (HY000): Your password has expired
一 问题描述
1.在项目现场,安装的是麒麟linux操作系统,安装完成mysql后,进行mysql 命令行登录时,报如下错误:
[root@localhost ~]# mysql -uroot -h127.0.0.1 -p
Enter password:
ERROR 1862 (HY000): Your password has expired. To log in you must change it using a client that supports expired passwords.
二 解决办法
1.修改 /etc/my.cnf,在 [mysqld] 添加:
skip-grant-tables=1
2.重启 mysqld 服务:
service mysql stop
service mysql start
或者执行如下命令:
systemctl restart mysqld
3.使用 root 用户登录到 mysql: (没有密码,直接按回车键)
mysql -uroot -p
进入myql的命令模式下,执行如下命令:
update mysql.user set password_expired='N' where user='root';
update mysql.user set authentication_string=password('root') where user='root' and Host = 'localhost';
flush privileges;
4、修改 /etc/my.cnf,注释掉:skip-grant-tables=1
5、重启 mysqld 服务:
service mysql stop
service mysql start
或者执行如下命令:
systemctl restart mysqld
6、修改密码:
mysql -uroot -p
alter user 'root'@'localhost' identified by '密码';
use mysql;
update user set user.Host='%' where user.User='root';
flush privileges;
7.再次登录
mysql -uroot -p root
进入之后:
mysql> set password=password('cloudiip123');
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'cloudiip123';
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
[root@localhost etc]# service mysql stop
Shutting down MySQL.. SUCCESS!
[root@localhost etc]# service mysql start
Starting MySQL. SUCCESS!
[root@localhost etc]#
相关文章
- mysql error
- 以docker的方式部署mysql数据库的方法
- 【MySQL高级】MySql中常用工具及Mysql 日志
- MySQL 设计数据表时,时间类型 datetime、bigint、timestamp MySQL日期函数
- mysql启动时报错:Starting MySQL... ERROR! The server quit without updating PID file (/opt/mysql/data/mysql.pid) 的解决方法
- MySQL数据恢复的九把瑞士军刀
- MySQL修改和删除触发器(DROP TRIGGER)
- 【用Navicat Premium 12连接mysql一报错】2059 - Authentication plugin ‘caching_sha2_password‘ cannot be loaded
- 【mysql问题】解决ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: YES)
- ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061),mysql服务已启动
- mac ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
- Mysql 5.7源码编译启动 报error问题:The server quit without updating PID file (/data/data_mysql/mysql.pid).
- MYSQL报错ERROR 1372 (HY000): Password hash should be a 41-digit hexadecimal number
- 基于 mysql 异步驱动的非阻塞 Mybatis【待验证】
- 解决mysql:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO/YES)
- spring中操作mysql数据库
- Error Code: 2006 - MySQL 鏈嶅姟鍣ㄥ凡绂荤嚎
- mysql内存,mysql oom
- mysql中的查询当做操作系统less使用
- 【3.2】【mysql基本实验】mysql GTID复制(基于空数据的配置)
- mysql常用压测工具
- mysql数据库导入sql文件时提示“Error Code: 1153 - Got a packet bigger than 'max_allowed_packet' bytes”解决办法
- 【MySQL】CentOS7实现MySQL读写分离环境搭建
- SQLAlchemy之mysql使用手册