【札记】Linux下 MySQL-5.7.17 tar.gz 包方式安装部署后出现密码过期的问题解决(不修改/etc/my.cnf文件)
来源:互联网 发布:docker java web 编辑:程序博客网 时间:2024/06/10 09:50
【问题描述】
在Oracle linux 6.8上安装完成MySQL-5.7.17(使用版本为:mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz)后:
[root@shh ~]# mysql --version
mysql Ver 14.14 Distrib 5.1.73, for redhat-linux-gnu (x86_64) using readline 5.1
# service mysqld start
命令行启动正常,登录出现问题:
[root@shh ~]# mysql -uroot -p
Enter password:
ERROR 1862 (HY000): Your password has expired. To log in you must change it using a client that supports expired passwords.
根据提示:密码过期,必须使用一个mysql客户端登录修改密码后才能使用。
mysql的提示与日志提示都是比较模糊的,只能根据经验进行问题排查。
【解决方法】
使用以下方式解决:
1、关闭mysql服务
[root@shh ~]# service mysqld status
MySQL running (30500)[ OK ]
[root@shh ~]#
[root@shh ~]#
[root@shh ~]# service mysqld stop
Shutting down MySQL..[ OK ]
[root@shh ~]#
2、进入mysql的工作目录 /usr/local/mysql/bin 使用mysql安全模式启动mysql,跳过mysql的登录权限验证
[root@shh ~]# cd /usr/local//mysql/bin/
[root@shh bin]# ./mysqld_safe --skip-grant-tables &
[1] 1557
[root@shh bin]# 2017-10-11T01:35:35.836730Z mysqld_safe Logging to '/usr/local/mysql/data/shhy-dw-application.err'.
2017-10-11T01:35:35.840516Z mysqld_safe Logging to '/usr/local/mysql/data/shhy-dw-application.err'.
2017-10-11T01:35:35.868903Z mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
执行完命令后,mysql会自动安全模式重启(注意:切记此时不要在再此shell窗口进行任何操作),此时,则新开ssh窗口或者使用远程机器(已安装MySQL客户端的Windows)的命令行进行连接访问:
3、命令行连接mysql数据库。此时无需指定密码。
[root@shh ~]# mysql -h10.10.9.35 -uroot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.7.17 MySQL Community Server (GPL)
Copyright (c) 2000, 2013, 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> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> select user,host,authentication_string,password_expired from mysql.user;
+-----------+-----------+-------------------------------------------+------------------+
| user | host | authentication_string | password_expired |
+-----------+-----------+-------------------------------------------+------------------+
| root | localhost | *895A2D9FF0E9EFA56E84678045BB050034435B72 | Y |
| mysql.sys | localhost | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | N |
+-----------+-----------+-------------------------------------------+------------------+
2 rows in set (0.00 sec)
mysql> update user set authentication_string=password('admin321') where user='root';
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 1
mysql> update user set password_expired='N' where user='root';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> update user set host='%' where user=root;
ERROR 1054 (42S22): Unknown column 'root' in 'where clause'
mysql> update user set host='%' where user='root';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select user,host,authentication_string,password_expired from mysql.user;
+-----------+-----------+-------------------------------------------+------------------+
| user | host | authentication_string | password_expired |
+-----------+-----------+-------------------------------------------+------------------+
| root | % | *2A29AD291780ABA691DA40E5900F63BCD40CB849 | N |
| mysql.sys | localhost | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | N |
+-----------+-----------+-------------------------------------------+------------------+
2 rows in set (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
4、如需要可永久关闭mysql密码过期功能限制:
修改全局配置文件 /etc/my.cnf 或者 /usr/local/mysql/support-files/my-default.cnf 文件(最后同时加上)
如下(如有则直接修改):
[mysqld]
default_password_lifetime=0
5、关闭当前使用安全MySQL模式的服务,直接kill -9 解决
^C
[root@shh bin]#
[root@shh bin]#
[root@shh bin]#
[root@shh bin]# ps -ef|grep mysql
root 1557 1437 0 09:35 pts/1 00:00:00 /bin/sh ./mysqld_safe --skip-grant-tables
mysql 1643 1557 0 09:35 pts/1 00:00:02 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --skip-grant-tables --log-error=/usr/local/mysql/data/shhy-dw-application.err --pid-file=/usr/local/mysql/data/shhy-dw-application.pid
root 1743 1719 0 09:51 pts/0 00:00:00 mysql -h10.10.9.35 -uroot
root 1953 1437 0 10:45 pts/1 00:00:00 grep mysql
[root@shh bin]# kill -9 1557
[root@shh bin]# kill -9 1643
[1]+ Killed ./mysqld_safe --skip-grant-tables
[root@shh bin]# ps -ef|grep mysql
root 1743 1719 0 09:51 pts/0 00:00:00 mysql -h10.10.9.35 -uroot
root 1956 1437 0 10:46 pts/1 00:00:00 grep mysql
重启服务,即可使用修改后的密码admin321进行访问了。
[root@shh bin]# service mysqld status
MySQL is not running, but PID file exists[FAILED]
[root@shh bin]# service mysqld start
Starting MySQL[ OK ]
[root@shh bin]# ps -ef|grep mysql
root 1997 1 0 10:48 pts/1 00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/data --pid-file=/usr/local/mysql/data/shhy-dw-application.pid
mysql 2099 1997 5 10:48 pts/1 00:00:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/usr/local/mysql/data/shhy-dw-application.err --pid-file=/usr/local/mysql/data/shhy-dw-application.pid
root 2131 1437 0 10:48 pts/1 00:00:00 grep mysql
[root@shh bin]#
[root@shh bin]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.17 MySQL Community Server (GPL)
Copyright (c) 2000, 2013, 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> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
在Oracle linux 6.8上安装完成MySQL-5.7.17(使用版本为:mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz)后:
[root@shh ~]# mysql --version
mysql Ver 14.14 Distrib 5.1.73, for redhat-linux-gnu (x86_64) using readline 5.1
# service mysqld start
命令行启动正常,登录出现问题:
[root@shh ~]# mysql -uroot -p
Enter password:
ERROR 1862 (HY000): Your password has expired. To log in you must change it using a client that supports expired passwords.
根据提示:密码过期,必须使用一个mysql客户端登录修改密码后才能使用。
mysql的提示与日志提示都是比较模糊的,只能根据经验进行问题排查。
【解决方法】
使用以下方式解决:
1、关闭mysql服务
[root@shh ~]# service mysqld status
MySQL running (30500)[ OK ]
[root@shh ~]#
[root@shh ~]#
[root@shh ~]# service mysqld stop
Shutting down MySQL..[ OK ]
[root@shh ~]#
2、进入mysql的工作目录 /usr/local/mysql/bin 使用mysql安全模式启动mysql,跳过mysql的登录权限验证
[root@shh ~]# cd /usr/local//mysql/bin/
[root@shh bin]# ./mysqld_safe --skip-grant-tables &
[1] 1557
[root@shh bin]# 2017-10-11T01:35:35.836730Z mysqld_safe Logging to '/usr/local/mysql/data/shhy-dw-application.err'.
2017-10-11T01:35:35.840516Z mysqld_safe Logging to '/usr/local/mysql/data/shhy-dw-application.err'.
2017-10-11T01:35:35.868903Z mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
执行完命令后,mysql会自动安全模式重启(注意:切记此时不要在再此shell窗口进行任何操作),此时,则新开ssh窗口或者使用远程机器(已安装MySQL客户端的Windows)的命令行进行连接访问:
3、命令行连接mysql数据库。此时无需指定密码。
[root@shh ~]# mysql -h10.10.9.35 -uroot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.7.17 MySQL Community Server (GPL)
Copyright (c) 2000, 2013, 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> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> select user,host,authentication_string,password_expired from mysql.user;
+-----------+-----------+-------------------------------------------+------------------+
| user | host | authentication_string | password_expired |
+-----------+-----------+-------------------------------------------+------------------+
| root | localhost | *895A2D9FF0E9EFA56E84678045BB050034435B72 | Y |
| mysql.sys | localhost | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | N |
+-----------+-----------+-------------------------------------------+------------------+
2 rows in set (0.00 sec)
mysql> update user set authentication_string=password('admin321') where user='root';
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 1
mysql> update user set password_expired='N' where user='root';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> update user set host='%' where user=root;
ERROR 1054 (42S22): Unknown column 'root' in 'where clause'
mysql> update user set host='%' where user='root';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select user,host,authentication_string,password_expired from mysql.user;
+-----------+-----------+-------------------------------------------+------------------+
| user | host | authentication_string | password_expired |
+-----------+-----------+-------------------------------------------+------------------+
| root | % | *2A29AD291780ABA691DA40E5900F63BCD40CB849 | N |
| mysql.sys | localhost | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | N |
+-----------+-----------+-------------------------------------------+------------------+
2 rows in set (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
4、如需要可永久关闭mysql密码过期功能限制:
修改全局配置文件 /etc/my.cnf 或者 /usr/local/mysql/support-files/my-default.cnf 文件(最后同时加上)
如下(如有则直接修改):
[mysqld]
default_password_lifetime=0
5、关闭当前使用安全MySQL模式的服务,直接kill -9 解决
^C
[root@shh bin]#
[root@shh bin]#
[root@shh bin]#
[root@shh bin]# ps -ef|grep mysql
root 1557 1437 0 09:35 pts/1 00:00:00 /bin/sh ./mysqld_safe --skip-grant-tables
mysql 1643 1557 0 09:35 pts/1 00:00:02 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --skip-grant-tables --log-error=/usr/local/mysql/data/shhy-dw-application.err --pid-file=/usr/local/mysql/data/shhy-dw-application.pid
root 1743 1719 0 09:51 pts/0 00:00:00 mysql -h10.10.9.35 -uroot
root 1953 1437 0 10:45 pts/1 00:00:00 grep mysql
[root@shh bin]# kill -9 1557
[root@shh bin]# kill -9 1643
[1]+ Killed ./mysqld_safe --skip-grant-tables
[root@shh bin]# ps -ef|grep mysql
root 1743 1719 0 09:51 pts/0 00:00:00 mysql -h10.10.9.35 -uroot
root 1956 1437 0 10:46 pts/1 00:00:00 grep mysql
重启服务,即可使用修改后的密码admin321进行访问了。
[root@shh bin]# service mysqld status
MySQL is not running, but PID file exists[FAILED]
[root@shh bin]# service mysqld start
Starting MySQL[ OK ]
[root@shh bin]# ps -ef|grep mysql
root 1997 1 0 10:48 pts/1 00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/data --pid-file=/usr/local/mysql/data/shhy-dw-application.pid
mysql 2099 1997 5 10:48 pts/1 00:00:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/usr/local/mysql/data/shhy-dw-application.err --pid-file=/usr/local/mysql/data/shhy-dw-application.pid
root 2131 1437 0 10:48 pts/1 00:00:00 grep mysql
[root@shh bin]#
[root@shh bin]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.17 MySQL Community Server (GPL)
Copyright (c) 2000, 2013, 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> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
阅读全文
0 0
- 【札记】Linux下 MySQL-5.7.17 tar.gz 包方式安装部署后出现密码过期的问题解决(不修改/etc/my.cnf文件)
- MySQL学习11_用rpm包安装的MySQL没有安装/etc/my.cnf文件
- (总结)CentOS下安装官方RPM包的MySQL后找不到my.cnf
- MySQL的my.cnf文件(解决5.7.18下没有my-default.cnf)
- Linux下tar.gz文件的安装
- 下安装官方RPM包的MySQL后找不到my.cnf
- Linux下安装完MySQL后找不到my.cnf文件原因
- Linux下安装完MySQL后找不到my.cnf文件原因
- linux下安装 mysql rpm安装 二进制包安装tar.gz 源码包安装 三种方式
- linux下如何安装.deb文件、tar.gz压缩包?
- linux下自己创建/etc/my.cnf文件导致启动mysql时报错:
- Linux下安装JDK(tar.gz格式的安装包)
- LINUX 环境下源码方式安装mysql(二)my.cnf配置细节详解
- mysql在linux下的my.cnf文件在哪里!
- mysql在linux下的my.cnf文件在哪里!
- mysql在linux下的my.cnf文件在哪里!
- mysql在linux下的my.cnf文件在哪里!
- mysql在linux下的my.cnf文件在哪里!
- MZERO微信支付流程的梳理
- 轻松解决oracle11g 空表不能exp导出的问题
- 第三周 求集合并集
- 使用truelicense实现用于JAVA工程license机制
- JNA加载DLL库
- 【札记】Linux下 MySQL-5.7.17 tar.gz 包方式安装部署后出现密码过期的问题解决(不修改/etc/my.cnf文件)
- python+appuim环境搭建(windows10系统)
- php用dom处理xml
- 动态代理模式的简易实现
- 第五周项目一 建立顺序栈算法库
- IDA动态调试Android的SO文件
- 设定Shell command的timeout
- Python 基础语法
- windows编译ffmpeg