安裝macos下的Mysql5.7.29-community

MySQL 社區辦下載地址
至於下載什麼版本,看着大小差不多其實都行。
在這裏插入圖片描述
我下載的是第一個安裝版,一路下一步即可。裝好後有個提示千萬別立刻關閉,這邊沒有截圖,這是生成的一串初始密碼。

2020-06-01T22:21:33.313881Z 1 [Note] A temporary password is generated for root@localhost: WFoU(uDvI1Ir
If you lose this password, please consult the section How to Reset the Root Password in the MySQL reference manual.

我們打開終端, 可以通過terminal去修改密碼了。

MacBook-Pro:local xuzhijie$ export PATH=$PATH:/usr/local/mysql/bin
MacBook-Pro:local xuzhijie$ vi ~/.bash_profile
MacBook-Pro:local xuzhijie$ mysql -u root -p
Enter password: WFoU(uDvI1Ir
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 159
Server version: 5.7.29

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;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

這邊你一上來用初始密碼進去執行命令,它會核善地提醒你你需要reset你的密碼。
那麼接着就在mysql裏面執行下面的命令

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'password';
Query OK, 0 rows affected (0.00 sec)

那麼現在你的新密碼就是password了。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章