在 macOS 上 brew install mysql - brew install mysql on macOS

語言: CN / TW / HK

問題:

I'm trying to setup up MySQL on mac os 10.6 using Homebrew by brew install mysql 5.1.52 .我正在嘗試通過brew install mysql 5.1.52使用 Homebrew 在 mac os 10.6 上設定 MySQL。

Everything goes well and I am also successful with the mysql_install_db .一切順利,我也成功使用mysql_install_db
However when I try to connect to the server using:但是,當我嘗試使用以下方法連線到伺服器時:

/usr/local/Cellar/mysql/5.1.52/bin/mysqladmin -u root password 'mypass'

I get:我得到:

/usr/local/Cellar/mysql/5.1.52/bin/mysqladmin: connect to server at 'localhost' 
failed error: 'Access denied for user 'root'@'localhost' (using password: NO)'

I've tried to access mysqladmin or mysql using -u root -proot as well,我也嘗試mysqladmin or mysql using -u root -proot訪問mysqladmin or mysql using -u root -proot
but it doesn't work with or without password.但無論有沒有密碼它都不起作用。

This is a brand new installation on a brand new machine and as far as I know the new installation must be accessible without a root password.這是在全新機器上的全新安裝,據我所知,新安裝必須無需 root 密碼即可訪問。 I also tried:我也試過:

/usr/local/Cellar/mysql/5.1.52/bin/mysql_secure_installation

but I also get但我也得到

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

解決方案:

參考一: https://stackoom.com/question/II0Z
參考二: brew install mysql on macOS
「其他文章」