若不考虑版本直接执行以下命令

brew install mysql

若要选择版本只要加上@版本即可,例如

brew install mysql@5.7 

安装完后启动mysql

mysql.server start

若服务未启动就会出现以下错误

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

若要关闭mysql

mysql.server stop

看到提示success则表示启动成功

Starting MySQL
. SUCCESS! 

现在登录mysql,默认情况下免密登录

mysql -u root

修改root密码,这是8.0的修改方法

alter user 'root'@'localhost' identified with mysql_native_password by 'root';

回车后有提示,则表示修改成功

Query OK, 0 rows affected (0.00 sec)

接着退出mysql

exit;

最后重新登录

mysql -u root -p

在输入密码则登录成功

相关文章:

  • 2021-12-09
  • 2021-11-19
  • 2021-09-19
  • 2021-12-06
  • 2021-12-05
  • 2021-12-15
  • 2021-12-12
猜你喜欢
  • 2021-12-17
  • 2021-11-25
  • 2022-01-06
  • 2021-09-08
  • 2021-12-10
  • 2021-12-10
  • 2021-08-21
相关资源
相似解决方案