当前位置: 首页 > MySQL > mac下brew方式安装mysql

mac下brew方式安装mysql

  • 分类:MySQL
  • 本文标签: mysql
  • 发布时间:2016-04-19 12:44:51
  • 作者:Ferman
  • 查看数: 340

本以为一两步就OK了,没想到brew安装mysql还遇到了几个坑。记录下来。

brew install mysql

然后执行

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

这是候会报错

mysql_install_db: [ERROR] unknown variable 'tmpdir=/tmp'

[ERROR]   Unrecognized options

在这里http://stackoverflow.com/questions/34345726/brew-install-mysql-on-mac-os-el-capitan的解决方法

可以看下,我试了并不行。在另一个解决方案里面有写因为mysql5.7后可能要遗弃 mysql_install_db.


这个错误你先不管,试着启动mysql.

mysql.server start

会报错 

ERROR! The server quit without updating PID file (/usr/local/var/mysql/xxx.pid)

然后查看日志:

cat /usr/local/var/mysql/xxx.local.err

日志如下,file operation文件操作权限有问题

2016-04-19T02:42:09.916629Z 0 [ERROR] InnoDB: Operating system error number 13 in a file operation.

2016-04-19T02:42:09.916636Z 0 [ERROR] InnoDB: The error means mysqld does not have the access rights to the directory.

2016-04-19T02:42:09.916647Z 0 [ERROR] InnoDB: Operating system error number 13 in a file operation.

2016-04-19T02:42:09.916651Z 0 [ERROR] InnoDB: The error means mysqld does not have the access rights to the directory.

2016-04-19T02:42:09.916655Z 0 [ERROR] InnoDB: Cannot open datafile './ibtmp1'

2016-04-19T02:42:09.916659Z 0 [ERROR] InnoDB: Unable to create the shared innodb_temporary

2016-04-19T02:42:09.916663Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Cannot open a file

2016-04-19T02:42:10.232319Z 0 [ERROR] Plugin 'InnoDB' init function returned error.

2016-04-19T02:42:10.232353Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.

2016-04-19T02:42:10.232366Z 0 [ERROR] Failed to initialize plugins.

2016-04-19T02:42:10.232373Z 0 [ERROR] Aborting


修改权限进行解决

chown _mysql /usr/local/var/mysql/*

其实还是不幸,权限没有转移过来,因为你安装mysql时所在你mac里面的name并不是 _mysql

粗暴一点,执行 

chmod -R 777 /usr/local/var/mysql/

再次 

mysql.server start

成功。啊,对,tmpdir不用管了。

设置用户名密码  

mysqladmin -u root password 'xxxxxx'

登录试试看

mysql -u root -p

 输入密码,登录成功


转载时请以 超链接的形式 注明:转自Ferman

                  

About me