数据库 OSX 装 mysql 遇到的一个问题!

alphaliu · 2012年03月16日 · 最后由 lgn21st 回复于 2013年03月05日 · 11789 次阅读

试着在 OSX 下用 homebrew 安装 mysql,前面还挺顺利的,后面的我想要为用户添加密码出问题了,提示如下:

mysqladmin -u alpha password 'abcdefg'

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 的方法:

1. install from brew

$ brew install mysql


2. 创建或修改/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'




3. init database

$ unset TMPDIR
$ mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp


4. start mysql

$ 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


5. secure mysql

# 按照提示一步一步执行
$ mysql_secure_installation


6. Change the root password if you need

$ mysqladmin -uroot -p'old_passowrd' password "new_password"


我们的论坛不支持 header 的 markdown 语法?cc @huachlee @Rei

#2 楼 @lgn21st Markdown 的 Header 是用 # 打头,不是 = 号

#3 楼 @huacnlee 啊,我突然发现我大脑短路了一下。

多谢@lgn21st,看来我没有做第五步,做过之后现在成功了,root 已经有密码了。不过,我在我的系统里面找不到 /usr/local/etc/my.cnf这个文件。

#5 楼 @AlphaLiu 这个文件要你自己创建,而且最好是在启动 mysql server 之前。

#6 楼 @lgn21st 谢谢,我明白了

#1 楼 @lgn21st

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 指向了一个不存在的目录。

需要 登录 后方可回复, 如果你还没有账号请 注册新账号