问题:
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