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了。