在網上試了一堆方式
有些甚至根本就年代久遠⋯⋯根本沒用
作業系統為 macos
Can't connect to local MySQL server through socket '/tmp/mysql.sock'
可以成功啟動
$ brew services start mysql
==> Successfully started `mysql` (label: homebrew.mxcl.mysql)
但是當下 mysql_secure_installation 指令時
$ mysql_secure_installation
Securing the MySQL server deployment.
Enter password for user root:
Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
或是直接 mysql
$ mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
另一種啟用
$ sudo mysql.server start
Password:
Starting MySQL
. ERROR! The server quit without updating PID file (/usr/local/var/mysql/xxx.local.pid).
(去找了 /usr/local/var/mysql/xxx.local.pid 沒有這個檔案,我甚至新增了一個 xxx.local.pid 也還是報錯)
搜尋了 mysql.sock 也沒有這個檔案
我利用 brew 切換去 mariadb 可以正常使用資料庫沒問題
$ brew unlink mysql
Unlinking /usr/local/Cellar/mysql/8.0.21... 90 symlinks removed
$ brew link mariadb
Linking /usr/local/Cellar/mariadb/10.4.13... 195 symlinks created
$ brew services stop mysql
Stopping `mysql`... (might take a while)
==> Successfully stopped `mysql` (label: homebrew.mxcl.mysql)
$ brew services start mariadb
==> Successfully started `mariadb` (label: homebrew.mxcl.mariadb)
只是我的 composer 依賴套件不支援 mariadb
(另外一個問題:https://ithelp.ithome.com.tw/questions/10199586 )
但由於我的套件似乎只支援 mysql 所以⋯⋯
實在不曉得到底是咋了
有大大遇過這個問題嗎?!