mac 通過brew 安裝的mysql啟動失敗解決方案

來源:互聯網
上載者:User

標籤:

最近重裝了mac系統,所有常用的軟體都需要重新安裝一遍,無疑安裝一個brew是個很好的選擇,關於brew是什麼,怎麼安裝建議去brew官網查看,附上地址:brew官網

安裝完成之後,安裝其他的軟體就特別方便了。

執行:

 brew install mysql

等成功安裝完成,結果想要登入的時候報了個錯誤:

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

網上搜尋了半天,找到解決方案,依次執行

unset TMPDIR

```bash mysql_install_db --verbose --user=root --basedir="$(brew --prefix mysql)"--datadir=/usr/local/var/mysql --tmpdir=/tmp

接下來啟動mysql```bashmysql.server start

啟動後就可以登入了,登入命令為:

mysql -uroot -p

然後提示輸入資料庫密碼,初始沒有密碼的情況下直接斷行符號,就進入資料庫了

如果想設定開機啟動,執行下面的命令

mkdir -p ~/Library/LaunchAgents
cp /usr/local/Cellar/mysql/5.6.16/homebrew.mxcl.mysql.plist ~/Library/LaunchAgents/ #5.6.16是資料庫版本號碼,根據你當時所安裝的版本號碼自己修改
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist

大功告成~


mac 通過brew 安裝的mysql啟動失敗解決方案

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.