按照如下设置
[root@hk ~]# vim /etc/my.cnf
#找到mysqld在之后添加
#skip-grant-tables
[root@hk ~]# service mysqld restart
Redirecting to /bin/systemctl restart mysqld.service
[root@hk ~]# mysql -u root
设置你的密码
mysql> update mysql.user set authentication_string=password('你的密码') where user='root' ;
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 1
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> exit;
Bye
正常登陆 登录后发现无法操作原因是密码太过于简单
[root@hk ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.7.21
Copyright (c) 2000, 2018, 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>
mysql> show databases
-> ;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql>
更改高安全级别密码
mysql> SET PASSWORD = PASSWORD('数字字母大写特殊字符');
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> show databases
-> ;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)
mysql>
正常使用