阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

MySQL 5.7安装后的一些配置

116次阅读
没有评论

共计 1348 个字符,预计需要花费 4 分钟才能阅读完成。

现在 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

正文完
星哥说事-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-22发表,共计1348字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中