時間:2020-05-15來源:電腦系統城作者:電腦系統城
Linux安裝好MySQL后,為了增加數據庫的安全性,在安裝時會為root用戶生成一個臨時的隨機密碼,存放在/var/log/mysqld.log 中。
[root@localhost mysql_bundle]# cat /var/log/mysqld.log | grep temp
2020-05-12T12:05:15.901037Z 1 [Note] A temporary password is generated for root@localhost: .fJJk*j&t4h6
2020-05-12T12:05:18.403371Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
這個.fJJk*j&t4h6就是臨時密碼。第一次登錄就使用這個密碼。
登錄后輸入show databases命令查看數據庫中有哪些庫,發現出現錯誤。
mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql>
這條錯誤語句時說必須使用ALTER USER重設密碼才可以執行這條語句。
那么接下來就重置密碼吧。
注意:密碼要符合復雜度規則,也就是說要包含大小寫字母、數字、特殊符號,并且長度不小于八位。否則會報錯,如下:
mysql> alter user root@localhost identified by '123456';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
mysql>
設置一個合格的密碼。
mysql> alter user root@localhost identified by 'MySQLroot123#';
Query OK, 0 rows affected (0.00 sec)
mysql>
[root@localhost mysql_bundle]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.7.29 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> exit
Bye
[root@localhost mysql_bundle]#
2022-03-09
MySQL存儲過程圖文實例講解教程2022-03-01
千萬級用戶系統SQL調優實戰分享2022-03-01
mysql遠程跨庫聯合查詢的示例為什么要主從同步? 主從同步的原理 MYSQL數據庫進行主從同步 創建兩個MYSQL數據庫 初始化,安裝主機數據庫 配置從機 測試主從同步 ...
2022-03-01
這篇文章主要介紹了銀河麒麟V10安裝MySQL8028的圖文教程,并詳細介紹了遠程訪問的實現方法,本文通過圖文命令給大家介紹的非常詳細...
2022-02-28