首先先找一下預設密碼是什麼
新版的mysql root 預設密碼已經不是空值
而是在第一次啟動時給予一個亂數字串

[root@pxc-example ~]# grep password /var/log/mysqld.log
2019-08-28T06:03:02.554033Z 1 [Note] A temporary password is generated for root@localhost: PrA!OOXXC3ir

預設使用mysqladmin 會出現以下錯誤
[root@pxc-example ~]# mysqladmin -u root -p password 'XXXXXX'
Enter password:
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.
mysqladmin: unable to change password; error: 'Percona XtraDB Cluster doesn't allow use of CURRENT_USER/USER function for USER operation while operating in cluster mode'

可以利用 mysql client 修改
[root@pxc-example ~]#  mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 15
Server version: 5.7.26-29-57-log

Copyright (c) 2009-2019 Percona LLC and/or its affiliates
Copyright (c) 2000, 2019, 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> ALTER USER 'root'@'localhost' IDENTIFIED BY 'NEW-Password';
Query OK, 0 rows affected (0.00 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec)

 

arrow
arrow
    創作者介紹
    創作者 helloworld 的頭像
    helloworld

    Hello World

    helloworld 發表在 痞客邦 留言(0) 人氣()