修改密码
配置/etc/my.cnf文件
skip-grant-tables
重启服务
service mysqld restart
mysql -uroot -p
直接回车
use mysql;
ALTER USER 'root'@'localhost' identified by 'yourpassword';
查看用户是否有远程连接权限
SELECT User, Host, Authentication_string FROM mysql.user;
如果没有%则需要赋予远程连接权限
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'yourpassword' WITH GRANT OPTION;
如果有%,则直接修改远程密码
ALTER USER 'root'@'%' identified by 'yourpassword';
查看用户状态
select host,user,password_expired,password_last_changed,password_lifetime,account_locked from mysql.user;
刷新
flush privileges;
exit
策略插件配置
查看mysql插件位置
show variables like 'plugin_dir';
要使服务器可用,插件库文件必须位于MySQL插件目录中(由plugin_dir系统变量命名的目录)。如果需要,通过在服务器启动时设置plugin_dir的值来配置插件目录位置。
配置文件修改
vim /etc/my.cnf
#skip-grant-tables
#加载密码策略插件
plugin-load-add=validate_password.so
#加载密码失败策略插件
plugin-load-add=connection_control.so
#密码长度的最小值
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
#密码过期时间(单位天)
default_password_lifetime=180
#允许密码错误次数5次
connection_control_failed_connections_threshold=5
#密码错误后最小等待时间1分钟(单位毫秒)
connection_control_min_connection_delay=60000
connection_control_failed_connections_threshold=5
#密码错误后最大等待时间(单位毫秒)
connection_control_max_connection_delay=2147483000
#允许因为网络异常导致链接失败的最大次数
max_connect_errors =10
#非交互式连接超时时间(单位秒)
wait_timeout=1200
#交互式连接超时时间(单位秒)
interactive_timeout=1200
重启服务
service mysqld restart
查看插件
show plugins;
https://www.cnblogs.com/kerrycode/p/8405862.html
http://www.manongjc.com/detail/18-pthznbuiperqlty.html