我正在尝试在mac os 10.6上使用Homebrew by brew安装MySQL 5.1.52。
一切都很顺利,我也成功地使用mysql_install_db。
然而,当我试图连接到服务器使用:
/usr/local/Cellar/mysql/5.1.52/bin/mysqladmin -u root password 'mypass'
我得到:
/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)'
我尝试访问mysqladmin或mysql使用-u root - root以及,
但是有没有密码都不行。
这是全新机器上的全新安装,据我所知,新安装必须在没有根密码的情况下访问。我还试过:
/usr/local/Cellar/mysql/5.1.52/bin/mysql_secure_installation
但我也得到了
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
我有同样的问题后,我试图重新启动mysql。
为了方便起见,我在.profile中使用了以下两个别名
alias mysql-stop='launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist'
alias mysql-start='launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist'
停止mysql后,然后尝试重新启动我遇到的问题,你有。我查看了launchctl加载,它报告了一个“nothing found to load”错误。
经过快速搜索,我找到了这个..
http://www.daveoncode.com/2013/02/01/solve-mac-osx-launchctl-nothing-found-to-load-error/
所以我更新了我的mysql-start别名如下
alias mysql-start='launchctl load -w -F ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist'
这解决了我的问题,可能对你有用。
我有同样的问题后,我试图重新启动mysql。
为了方便起见,我在.profile中使用了以下两个别名
alias mysql-stop='launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist'
alias mysql-start='launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist'
停止mysql后,然后尝试重新启动我遇到的问题,你有。我查看了launchctl加载,它报告了一个“nothing found to load”错误。
经过快速搜索,我找到了这个..
http://www.daveoncode.com/2013/02/01/solve-mac-osx-launchctl-nothing-found-to-load-error/
所以我更新了我的mysql-start别名如下
alias mysql-start='launchctl load -w -F ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist'
这解决了我的问题,可能对你有用。
下面是Sedorner上面写的关于如何从你的Mac上删除所有MySQL,然后用Brew Way安装它的详细说明:
根据技术实验室完全删除MySQL
ps -ax | grep mysql
stop and kill any MySQL processes
sudo rm /usr/local/mysql
sudo rm -rf /usr/local/var/mysql
sudo rm -rf /usr/local/mysql*
sudo rm ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/My*
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
edit /etc/hostconfig and remove the line MYSQLCOM=-YES-
rm -rf ~/Library/PreferencePanes/My*
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*
sudo rm -rf /private/var/db/receipts/*mysql*
sudo rm -rf /tmp/mysql*
try to run mysql, it shouldn't work
从这个StackOverflow的答案酿造安装MySQL每用户Sedorner
酿造医生和修复任何错误
Brew remove mysql
啤酒清理
酿造更新
安装mysql
设置TMPDIR
Mysql_install_db——verbose——user= ' whoami '——basedir="$(brew——prefix mysql)"——datadir=/usr/local/var/mysql——tmpdir=/tmp # whoami inline执行
mysql。服务器启动
运行Brew建议的命令,将MySQL添加到launchctl中,以便在启动时自动启动
Mysql现在应该可以正常工作并一直正常运行
祝成功。
我认为如果已经安装了旧版本的mysql,就会出现这种情况。我也遇到了同样的问题,上面的解决方案对我都不起作用。我是这样安排的:
使用brew的remove & cleanup命令,卸载launchctl脚本,然后删除mysql目录在/usr/local/var,删除我现有的/etc/my.cnf(留给你,如果它适用)和launchctl plist
更新plist的字符串。还要注意,您的备用安全脚本目录将基于您正在安装的MySQL版本。
循序渐进:
brew remove mysql
brew cleanup
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
rm ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
sudo rm -rf /usr/local/var/mysql
然后我从头开始:
installed mysql with brew install mysql
ran the commands brew suggested: (see note: below)
unset TMPDIR
mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
Start mysql with mysql.server start command, to be able to log on it
Used the alternate security script:
/usr/local/Cellar/mysql/5.5.10/bin/mysql_secure_installation
Followed the launchctl section from the brew package script output such as,
#start
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
#stop
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
注意:啤酒清理的——force位也会清理过时的酒桶,这是一个新的自制啤酒功能。
注意第二点:一个评论者说第二步不是必需的。我不想测试它,所以是YMMV!