环境: CentOS7
mysql源选择本地源:
[root@master ~]# ll win-share/mysql/57/ 总用量 207346 -rwxrwxrwx. 1 root root 26468960 2月 28 22:17 mysql-community-client-5.7.33-1.el7.x86_64.rpm -rwxrwxrwx. 1 root root 315280 12月 11 13:20 mysql-community-common-5.7.33-1.el7.x86_64.rpm -rwxrwxrwx. 1 root root 2458780 12月 11 13:21 mysql-community-libs-5.7.33-1.el7.x86_64.rpm -rwxrwxrwx. 1 root root 1260364 12月 11 13:21 mysql-community-libs-compat-5.7.33-1.el7.x86_64.rpm -rwxrwxrwx. 1 root root 181817592 2月 26 16:45 mysql-community-server-5.7.33-1.el7.x86_64.rpm drwxrwxrwx. 1 root root 0 3月 2 10:36 repodata
安装:
[root@master ~]# yum install mysql-community-server
查看mysql的登录密码: ?O:Askd)s9tu就是系统生成的密码
[root@master ~]# grep "temporary password is generated" /var/log/mysqld.log 2021-03-09T23:36:31.157066Z 1 [Note] A temporary password is generated for root@localhost: ?O:Askd)s9tu
登录:因密码中有特殊字符所以要在-p后加“”(双引号)
[root@master ~]# mysql -uroot -p"?O:Askd)s9tu" mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 4 Server version: 5.7.33 Copyright (c) 2000, 2021, Oracle and/or its affiliates. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement. mysql>
修改密码强度限制:(默认8位、大小写字母、特殊符号、数字)
注意:因为是实验环境密码强度可以降低,如果是生产环境要注意安全。
先修改默认密码:否则什么都不会让你操作
mysql> ALTER USER ‘root‘@‘localhost‘ IDENTIFIED BY ‘?O:Askd)s9tu1‘; Query OK, 0 rows affected (0.00 sec)
查看密码规则:
mysql> SHOW VARIABLES LIKE ‘validate_password%‘; +--------------------------------------+--------+ | Variable_name | Value | +--------------------------------------+--------+ | validate_password_check_user_name | OFF | | validate_password_dictionary_file | | | 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 | +--------------------------------------+--------+ 7 rows in set (0.01 sec)
在mysql降低密码强度等级,
mysql> set global validate_password_policy=LOW; Query OK, 0 rows affected (0.00 sec)
密码长度设为6 默认8
mysql> set global validate_password_length=6; Query OK, 0 rows affected (0.01 sec)
设置密码为123456
mysql> ALTER USER ‘root‘@‘localhost‘ IDENTIFIED BY ‘123456‘; Query OK, 0 rows affected (0.00 sec)
参考:
http://blog.csdn.net/wohiusdashi/article/details/89358071
http://zhuanlan.zhihu.com/p/200909519