--initialize specified but the data directory has files in it. Aborting

Mac用brew安装 mysql 报错

MacBook-Pro:mysql apple$ brew postinstall mysql
==> /usr/local/Cellar/mysql/5.7.12/bin/mysqld --initialize-insecure --user=apple
Last 15 lines from /Users/apple/Library/Logs/Homebrew/mysql/01.mysqld:
2016-06-30 15:14:37 +0800

/usr/local/Cellar/mysql/5.7.12/bin/mysqld
--initialize-insecure
--user=apple
--basedir=/usr/local/Cellar/mysql/5.7.12
--datadir=/usr/local/var/mysql
--tmpdir=/tmp

2016-06-30T07:14:37.265699Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-06-30T07:14:37.267725Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
2016-06-30T07:14:37.267757Z 0 [ERROR] Aborting


READ THIS: https://git.io/brew-troubleshooting
If reporting this issue please do so at (not Homebrew/brew):
  https://github.com/Homebrew/homebrew-core/issues


解决方法

保证 --datadir目录为空。。 /usr/local/var/mysql 这个目录 

我删除目录的内容 还是会自动生成,删除了这mysql然后马上执行brew postinstall mysql

然后奇迹出现了

MacBook-Pro:mysql apple$ brew postinstall mysql
==> /usr/local/Cellar/mysql/5.7.12/bin/mysqld --initialize-insecure --user=apple --basedir=/usr/local/Cellar/mysql/5.7.1
MacBook-Pro:mysql apple$ mysql.server start
Starting MySQL
 SUCCESS! 

服务器也启动好了


自动生成原因可能是mysqld这个服务器已经启动。下次遇到可以试试 看活动监视器里有没有mysqld这个进程,有就Kill掉

  • 19
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值