试着在 OSX 下用 homebrew 安装 mysql,前面还挺顺利的,后面的我想要为用户添加密码出问题了,提示如下:
mysqladmin: Can't turn off logging; error: 'Access denied; you need (at least one of) the SUPER privilege(s) for this operation'
google 了一圈也没找到解决方案,只能来这里问问了。请帮帮忙!
通过 Homebrew 安装 MySQL 的方法:
$ brew install mysql
/usr/local/etc/my.cnf
下面这个是个例子[client]
port = 3306
socket = /tmp/mysql.sock
default-character-set = utf8
[mysqld]
collation-server = utf8_unicode_ci
character-set-server = utf8
init-connect ='SET NAMES utf8'
max_allowed_packet = 64M
bind-address = 127.0.0.1
port = 3306
socket = /tmp/mysql.sock
innodb_file_per_table=1
[mysqld_safe]
timezone = '+0:00'
$ unset TMPDIR
$ mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
$ mkdir -p ~/Library/LaunchAgents
$ cp /usr/local/Cellar/mysql/5.5.20/homebrew.mxcl.mysql.plist ~/Library/LaunchAgents/
$ launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
# 按照提示一步一步执行
$ mysql_secure_installation
$ mysqladmin -uroot -p'old_passowrd' password "new_password"
多谢@lgn21st,看来我没有做第五步,做过之后现在成功了,root 已经有密码了。不过,我在我的系统里面找不到 /usr/local/etc/my.cnf这个文件。
bogon:~ feng$ mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
WARNING: The host 'bogon' could not be looked up with /usr/local/opt/mysql/bin/resolveip.
This probably means that your libc libraries are not 100 % compatible
with this binary MySQL version. The MySQL daemon, mysqld, should work
normally with the exception that host name resolving will not work.
This means that you should use IP addresses instead of hostnames
when specifying MySQL privileges !
FATAL ERROR: The parent directory for the data directory '/usr/local/var/mysql' does not exist.
If that path was really intended, please create that directory path and then
restart this script.
If some other path was intended, please use the correct path when restarting this script.
请问这个是什么情况呢?
'/usr/local/var/mysql' does not exist.
说明你的 mysql 配置文件有问题,把 socket 指向了一个不存在的目录。