问题描述
我刚刚升级到 MacOS Big Sur,我发现我无法使用 MysqL -u root
(没有密码)登录到 MysqL 控制台。
ERROR 2002 (HY000): Can't connect to local MysqL server through socket '/tmp/MysqL.sock' (2)
我用 brew (brew install mariadb
) 安装了 MariaDB
Xuans-MacBook-Pro:~ xuan$ MysqLd
2020-12-21 15:46:27 0 [Note] MysqLd (MysqLd 10.5.8-MariaDB) starting as process 2091 ...
2020-12-21 15:46:27 0 [Warning] Can't create test file /usr/local/var/MysqL/Xuans-MacBook-Pro-2.lower-test
2020-12-21 15:46:27 0 [ERROR] MysqLd: File '/usr/local/var/MysqL/aria_log_control' not found (Errcode: 13 "Permission denied")
2020-12-21 15:46:27 0 [ERROR] MysqLd: Got error 'Can't open file' when trying to use aria control file '/usr/local/var/MysqL/aria_log_control'
2020-12-21 15:46:27 0 [ERROR] Plugin 'Aria' init function returned error.
2020-12-21 15:46:27 0 [ERROR] Plugin 'Aria' registration as a STORAGE ENGINE Failed.
2020-12-21 15:46:27 0 [ERROR] InnoDB: The innodb_system data file 'ibdata1' must be writable
2020-12-21 15:46:27 0 [ERROR] InnoDB: The innodb_system data file 'ibdata1' must be writable
2020-12-21 15:46:27 0 [ERROR] Plugin 'InnoDB' init function returned error.
2020-12-21 15:46:27 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE Failed.
2020-12-21 15:46:27 0 [Note] Plugin 'FeedBACK' is disabled.
2020-12-21 15:46:27 0 [ERROR] Could not open MysqL.plugin table: "Table 'MysqL.plugin' doesn't exist". Some plugins may be not loaded
2020-12-21 15:46:27 0 [ERROR] Failed to initialize plugins.
2020-12-21 15:46:27 0 [ERROR] Aborting
这是/usr/local/var/MysqL/
的许可
drwxr-xr-x 68 xuan admin 2176 21 Dec 15:48 MysqL
Xuans-MacBook-Pro:xuan$ MysqLd --help --verbose | grep sock
socket /tmp/MysqL.sock
unix-socket ON
有什么建议吗?
解决方法
我在运行 big sur 11.1 的 i9 的 2018 年 macbook pro 上遇到了同样的问题 我可以使用 mysql workbench 和 datagrip 链接到 mysql 数据库没问题,但是当我尝试从终端访问 mysql 时,我得到“无法通过套接字连接到本地 MYSQL 服务器”。 我回到 /usr/local/mysql/bin 并运行 ./mysql -u root -p 并连接。 这是一个很大的sur安全问题吗? MAMP 正在运行。 MYSQL 编辑器运行正常。似乎 big sur 不允许套接字通过 MAMP 连接。
,通过套接字以 root 用户身份登录要求套接字的所有者是 root,而不是任何其他用户,因为身份验证将通过 unix 套接字身份验证执行。
所以一个简单的 sudo mysql -uroot
应该可以工作。