--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掉

你可能感兴趣的:(编程)