苏州吴江区建设局网站,小程序建站公司,无锡网站seo外包,微信开发公司原文链接#xff1a;http://www.cnblogs.com/jonsea/p/5510219.html
---------------------------------------------------------------------------
松门一枝花补充
最简单的方法#xff1a;
1、配置文件中把密码策略关了。本文中间部分有介绍。
2、重启服务
3、用my…原文链接http://www.cnblogs.com/jonsea/p/5510219.html
---------------------------------------------------------------------------
松门一枝花补充
最简单的方法
1、配置文件中把密码策略关了。本文中间部分有介绍。
2、重启服务
3、用mysql生成的临时密码登录。见本文末尾。
4、修改root密码。set passwordpassword(新密码);
5、退出登录再登录。就可以操作了。 在Centos6.6上安装MySQL5.7.12时遇到了一个问题 安装后在/root目录下没有发现有.mysql_secret这个文件所以没有没法按照官方文档上说的那样使用这里记录下 解决方式 首先修改MySQL授权登录方式---跳过授权验证方式启动MySQL[roottest ~]# mysqld_safe --skip-grant-tables
[1] 3401
[roottest ~]# 2016-05-19T12:47:56.564385Z mysqld_safe Logging to /var/log/mysqld.log.
2016-05-19T12:47:56.589376Z mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
检查MySQL启动情况
[roottest ~]# ps -ef | grep mysql
root 3401 2880 0 20:47 pts/1 00:00:00 /bin/sh /usr/bin/mysqld_safe --skip-grant-tables
mysql 3548 3401 0 20:47 pts/1 00:00:00 /usr/sbin/mysqld --basedir/usr --datadir/var/lib/mysql --plugin-dir/usr/lib64/mysql/plugin --usermysql --skip-grant-tables --log-error/var/log/mysqld.log --pid-file/var/run/mysqld/mysqld.pid --socket/var/lib/mysql/mysql.sock
这时登录MySQL不再需要验证[roottest ~]# mysql 成功登录MySQL后 切换到mysql系统库
mysql use mysql;修改root账户登录密码
mysql update user set passwordpassword() where userroot;
ERROR 1054 (42S22): Unknown column password in field list
---报错没有password这个数据字段列描述user表
mysql desc user;
...
| authentication_string | text | YES | | NULL | |
| password_expired | enum(N,Y) | NO | | N | |
| password_last_changed | timestamp | YES | | NULL | |
| password_lifetime | smallint(5) unsigned | YES | | NULL | |
| account_locked | enum(N,Y) | NO | | N | |
----------------------------------------------------------------------------------------------------
---没发现password列但是找到这5个跟密码相关的数据字段查询一下相关的密码信息
mysql select user,host,authentication_string,password_expired from user;
-----------------------------------------------------------------------------------
| user | host | authentication_string | password_expired |
-----------------------------------------------------------------------------------
| root | localhost | *9AA01F6E2A80A823ACB72CC07337E2911404B5B8 | Y |
| mysql.sys | localhost | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | N |
-----------------------------------------------------------------------------------
---到这里不难发现root账户的密码已过期还比5.6多出了一个mysql.sys用户修改密码
mysql update user set authentication_stringpassword(123abc) where userroot;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0mysql flush privileges;
Query OK, 0 rows affected (0.00 sec)mysql exit 密码修改成功,测试 重启MySQL
[roottest ]# /etc/init.d/mysqld restart登录测试:
[roottest ]# mysql -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.12-enterprise-commercial-advanced
...
mysql show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
---报错需要使用alter user 修改密码
mysql alter user rootlocalhost identified by oracle;
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
---报错密码不满足制定的密码负责度要求
mysql alter user rootlocalhost identified by Abc!123D;
Query OK, 0 rows affected (0.01 sec)mysql show databases;
--------------------
| Database |
--------------------
| information_schema |
| mysql |
| performance_schema |
| sys |
--------------------
4 rows in set (0.00 sec) 关于密码策略 mysql SHOW VARIABLES LIKE validate_password%;
----------------------------------------------
| Variable_name | Value |
----------------------------------------------
| validate_password_dictionary_file | |
| validate_password_length | 8 |
| validate_password_mixed_case_count | 1 |
| validate_password_number_count | 1 |
| validate_password_policy | MEDIUM |
| validate_password_special_char_count | 1 |
----------------------------------------------
6 rows in set (0.02 sec) mysql show plugins;
---------------------------------------------------------------------------------------------
| Name | Status | Type | Library | License |
---------------------------------------------------------------------------------------------
| binlog | ACTIVE | STORAGE ENGINE | NULL | PROPRIETARY |...
| validate_password | ACTIVE | VALIDATE PASSWORD | validate_password.so | PROPRIETARY |
---------------------------------------------------------------------------------------------
---可以通过在配置文件[mysqld]标签中添加 validate_passworoff 来关闭密码策略
如下:
...
| validate_password | DISABLED | VALIDATE PASSWORD | validate_password.so | PROPRIETARY |
---------------------------------------------------------------------------------------------
配置文件位置
[rootmaster ~]# find / -name my.cnf
/etc/my.cnf
总结 1) 安装好mysql后第一次启动时root管理密码会在/root/.mysql_secret中随机生成 2) 至5.7后MySQL的 mysql.user 表中的密码字段由之前的 password 改为 authentication_string 3) 使用--skip-grant-tables 参数启动跳过MySQL的授权验证--skip-networking参数跳过远程登录 4) 修改MySQL密码方式 法1update user set authentication_stringpassword(123abc) where userroot; 法2set passwordpassword(newpassword); 法3alter user rootlocalhost identified by oracle; 法4在shell下使用MySQL工具mysqladmin -uroot -poldpassword pasword newpassword 5) 关于MySQL密码策略
决定是否使用该插件(及强制/永久强制使用)--validate-passwordON/OFF/FORCE/FORCE_PLUS_PERMANENTvalidate_password_dictionary_file 插件用于验证密码强度的字典文件路径。validate_password_length 密码最小长度。validate_password_mixed_case_count 密码至少要包含的小写字母个数和大写字母个数。validate_password_number_count 密码至少要包含的数字个数。validate_password_policy 密码强度检查等级0/LOW、1/MEDIUM、2/STRONG。validate_password_special_char_count 密码至少要包含的特殊字符数。其中关于validate_password_policy-密码强度检查等级0/LOW 只检查长度。1/MEDIUM 检查长度、数字、大小写、特殊字符。2/STRONG 检查长度、数字、大小写、特殊字符字典文件。后记 经过一段时间后发现mysql初始密码原来被记录到了日志文件中 查找日志位置[roottest /var/lib/mysql]# ps -ef | grep mysql
root 5604 1 0 22:40 pts/1 00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir/var/lib/mysql --socket/var/lib/mysql/mysql.sock --pid-file/var/run/mysqld/mysqld.pid --basedir/usr --usermysql
mysql 5802 5604 5 22:40 pts/1 00:00:00 /usr/sbin/mysqld --basedir/usr --datadir/var/lib/mysql --plugin-dir/usr/lib64/mysql/plugin --usermysql --log-error/var/log/mysqld.log --pid-file/var/run/mysqld/mysqld.pid --socket/var/lib/mysql/mysql.sock
root 5837 2880 0 22:40 pts/1 00:00:00 grep --color mysql
藏在日志文件中的临时密码
[roottest /var/lib/mysql]# grep A temporary password /var/log/mysqld.log
2016-05-17T16:46:53.059632Z 1 [Note] A temporary password is generated for rootlocalhost: wGVA#to(4tu