在MacOS上输入“mysql -u root -p”报错:ERROR 2002 (HY000): Can‘t connect to local MySQL server through socket

 mac上登录mysql出现以下问题:

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

主要原因是你的mysql服务没有启动,输入一下命令启动:

mysql.server start

启动成功!

Starting MySQL
.. SUCCESS!

再次输入mysql -u root -p:

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.32 Homebrew

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

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>

你可能感兴趣的:(学习经验分享,mysql,java,数据库)