最近重裝了mac系統,全部經常使用的軟件都須要從新安裝一遍,無疑安裝一個brew是個很好的選擇,關於brew是什麼,怎麼安裝建議去brew官網查看,附上地址:brew官網 html
安裝完成以後,安裝其餘的軟件就特別方便了。 mysql
執行: sql
brew install mysql
等成功安裝完成,結果想要登陸的時候報了個錯誤: docker
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 bash
接下來啓動mysql ```bash mysql.server start
啓動後就能夠登陸了,登陸命令爲: socket
mysql -uroot -p
而後提示輸入數據庫密碼,初始沒有密碼的狀況下直接回車,就進入數據庫了 ui
若是想設置開機啓動,執行下面的命令 spa
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
大功告成~ code
Mysql 安裝後沒法link,執行」brew docker」報以下問題:
1
2
3
4
|
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into/usr/local
Could notsymlinkshare/man/man8/mysqld.8
/usr/local/share/man/man8is not writable.
|
執行好事命令解決問題:
1
|
sudochown-R `whoami`/usr/local
|