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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章