systemctl status mysqld.service ● mysqld.service - MySQL Server Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled) Active: active (running) since Wed 2020-05-13 23:57:41 HKT; 18s ago Docs: man:mysqld(8) http://dev.mysql.com/doc/refman/en/using-systemd.html Process: 9563 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS) Main PID: 9649 (mysqld) Status: "Server is operational" Tasks: 39 CGroup: /system.slice/mysqld.service └─9649 /usr/sbin/mysqld
May 13 23:57:34 CentOS.highning.com systemd[1]: Starting MySQL Server... May 13 23:57:41 CentOS.highning.com systemd[1]: Started MySQL Server. 找出root初始密码
grep "password" /var/log/mysqld.log 2020-05-13T15:57:37.815353Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: 9*CxxNRWHqmL
进入数据库:
mysql -uroot -p 输入密码(密码是上面查询到的 ,/wsw6gif;eH ),此时不能操作数据库,必须修改密码之后才能操作数据库
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password'; 其中‘new password'替换成你要设置的密码,注意:密码设置必须要大小写字母数字和特殊符号(,/';:等),不然不能配置成功
Microsoft Windows [版本 10.0.18363.778] (c) 2019 Microsoft Corporation。保留所有权利。
C:/Users/highning>mysql -h 192.168.88.88 -P 3306 -u root -p Enter password: ******** Welcome to the MySQL monitor. Commands end with ; or /g. Your MySQL connection id is 10 Server version: 8.0.20 MySQL Community Server - GPL
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
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> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 4 rows in set (0.00 sec)
mysql> 修改密码安全策略,改为LOW,密码长度最小6位
mysql> SHOW VARIABLES LIKE 'validate_password%'; +--------------------------------------+--------+ | Variable_name | Value | +--------------------------------------+--------+ | validate_password.check_user_name | ON | | 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.00 sec)
mysql> set global validate_password.policy=LOW; Query OK, 0 rows affected (0.00 sec)
mysql> set global validate_password.length=6; Query OK, 0 rows affected (0.00 sec)
mysql> SHOW VARIABLES LIKE 'validate_password%'; +--------------------------------------+-------+ | Variable_name | Value | +--------------------------------------+-------+ | validate_password.check_user_name | ON | | validate_password.dictionary_file | | | validate_password.length | 6 | | validate_password.mixed_case_count | 1 | | validate_password.number_count | 1 | | validate_password.policy | LOW | | validate_password.special_char_count | 1 | +--------------------------------------+-------+ 7 rows in set (0.00 sec) 关于 mysql 密码策略相关参数;