手机版
你好,游客 登录 注册 搜索
背景:
阅读新闻

MySQL 5.7安装后的一些配置

[日期:2017-02-02] 来源:Linux社区  作者:fengwan [字体: ]

现在MySQL 5.7之后新增了很多功能,其中最明显的就是密码增强的配置。

安装完MySQL 5.7之后默认是没有用户名密码的。
/etc/init.d/mysqld stop

mysqld_safe --skip-grant-tables &
如果此时不想被远程连接:mysqld_safe --skip-grant-tables --skip-networking &

MySQL 5.7.15之后就没有mysqld_safe了,使用
mysqld --user=mysql --explicit_defaults_for_timestamp=1 --skip-grant-tables

完成之后使用如下重置密码
update set authentication_string=password('password') where user='root';

然后就可以无密码登录了,接着修改密码
alter user 'root'@'localhost' identified by 'password';
不建议用此方法:否则后面会报ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

#update mysql.user set authentication_string=password("password") where user="root";
 
killall mysqld
/etc/init.d/mysqld start
就可以用密码登录了
mysql -uroot -p
但是会发现
mysql> show variables like '%char%';
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> alter user 'root'@'localhost' identified by 'password';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
关闭MySQL强密码插件
修改MySQL的启动脚本
大约在132行位置修改
$exec  --datadir="$datadir" --socket="$socketfile" --validate-password=OFF\
增加红色部分即可
service mysqld restart
mysql> alter user 'root'@'localhost' identified by 'password';
就OK了

总结:

mysql.user表结构的更改原来password字段更改为authentication_string字段

新增validate-password插件不需要强密码的就关闭吧。生产环境不建议

CentOS 7源码安装MySQL 5.7.17 http://www.linuxidc.com/Linux/2017-02/140133.htm

本文永久更新链接地址http://www.linuxidc.com/Linux/2017-02/140149.htm

linux
相关资讯       MySQL 5.7  MySQL 5.7安装  MySQL 5.7配置 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款