1.安装mysql,目前默认安装的是mysql8.0.19
[geandeiMac:~ gean$ brew install mysql
2.启动mysql服务
[geandeiMac:~ gean$ mysql.server start
3.登陆mysql
输入use mysql
设置密码:ALTER USER 'root'@'localhost' IDENTIFIED WITH MYSQL_NATIVE_PASSWORD BY '123456';
[geandeiMac:~ gean$ mysql -u root -p
[Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 19
Server version: 8.0.19 Homebrew
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> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH MYSQL_NATIVE_PASSWORD BY '123456';
Query OK, 0 rows affected (0.01 sec)
4.quit退出mysql重新登陆并验证密码