普拉多VX

人生一路,不问来时,不知归期

0%

Mysql 5.7 设置密码无效

修改方法

按以前设置的mysql方法均无效,查询了半天居然是改了字段。现将方法记录下。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
mysql> update mysql.user SET authentication_string=PASSWORD('xxxxxxxx'), plugin='mysql_native_password' WHERE user='root';        
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 1

mysql> \q
Bye
root@monitor:/etc/mysql#
root@monitor:/etc/mysql# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.33-0ubuntu0.18.04.1 (Ubuntu)

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> \q
Bye
root@monitor:/etc/mysql#
root@monitor:/etc/mysql#
root@monitor:/etc/mysql# /etc/init.d/mysql restart
[ ok ] Restarting mysql (via systemctl): mysql.service.
root@monitor:/etc/mysql# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

记得设置完需要重启下mysql