参考:
https://blog.csdn.net/weixx3/article/details/80782479
https://blog.csdn.net/hello_world_qwp/article/details/79551789
1.sudo apt-get install mysql-server
2. 初始化配置
sudo mysql_secure_installation
3.检查mysql服务状态
systemctl status mysql.service
4.登录
sudo mysql -uroot -p
GRANT ALL PRIVILEGES ON *.* TO root@localhost IDENTIFIED BY "123456";
create database basename DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
GRANT ALL PRIVILEGES ON bk.* TO lj@"%" IDENTIFIED BY "123456";
刷新权限
FLUSHPRIVILEGES;
设置用户,密码,localhost就是本地访问,配置成%就是所有主机都可连接,指定数据库
5.设置密码强度
SHOW VARIABLES LIKE 'validate_password%';
set global validate_password_policy=LOW;
set global validate_password_length=6;
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
6.关于 mysql 密码策略相关参数;
1)、validate_password_length 固定密码的总长度;
2)、validate_password_dictionary_file 指定密码验证的文件路径;
3)、validate_password_mixed_case_count 整个密码中至少要包含大/小写字母的总个数;
4)、validate_password_number_count 整个密码中至少要包含阿拉伯数字的个数;
5)、validate_password_policy 指定密码的强度验证等级,默认为 MEDIUM;
关于 validate_password_policy 的取值:
0/LOW:只验证长度;
1/MEDIUM:验证长度、数字、大小写、特殊字符;
2/STRONG:验证长度、数字、大小写、特殊字符、字典文件;
6)、validate_password_special_char_count 整个密码中至少要包含特殊字符的个数;