操作:
mysql -u root -p
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
解决:
mysqld
/* 打印信息 */
2023-07-20T03:21:36.575602Z 0 [System] [MY-010116] [Server] /usr/local/Cellar/mysql/8.0.30/bin/mysqld (mysqld 8.0.30) starting as process 3333
2023-07-20T03:21:36.601452Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /usr/local/var/mysql/ is case insensitive
2023-07-20T03:21:36.661034Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-07-20T03:21:39.221076Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2023-07-20T03:21:39.792779Z 0 [System] [MY-010229] [Server] Starting XA crash recovery...
2023-07-20T03:21:39.804301Z 0 [System] [MY-010232] [Server] XA crash recovery finished.
2023-07-20T03:21:39.919110Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2023-07-20T03:21:39.919167Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2023-07-20T03:21:39.956711Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '127.0.0.1' port: 33060, socket: /tmp/mysqlx.sock
2023-07-20T03:21:39.957225Z 0 [System] [MY-010931] [Server] /usr/local/Cellar/mysql/8.0.30/bin/mysqld: ready for connections. Version: '8.0.30' socket: '/tmp/mysql.sock' port: 3306 Homebrew.
启动了服务 之后 自动创建了'/tmp/mysql.sock' 就能正常使用mysql指令 打开数据库了