mysql 5.7开发者安装_MySQL 5.7安装后的一些配置-阿里云开发者社区

现在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插件不需要强密码的就关闭吧。生产环境不建议

本文转自 rong341233 51CTO博客,原文链接:http://blog.51cto.com/fengwan/1874509

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值