码迷,mamicode.com
首页 > 数据库 > 详细

MySQL 5.7安装后的一些配置

时间:2016-11-19 18:31:10      阅读:278      评论:0      收藏:0      [点我收藏+]

标签:mysql password

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


安装完MySQL 5.7之后默认是没有用户名密码的。

/etc/init.d/mysqld stop

mysqld_safe --skip-grant-tables & 

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

然后就可以无密码登录了,接着修改密码

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了


总结:

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

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



本文出自 “枫林晚” 博客,请务必保留此出处http://fengwan.blog.51cto.com/508652/1874509

MySQL 5.7安装后的一些配置

标签:mysql password

原文地址:http://fengwan.blog.51cto.com/508652/1874509

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!