2014-02-24 72 views
7

我在小牛上安裝MySQL和Homebrew有瘋狂的問題。我知道有一個類似的命名主題,但我已經嘗試了與至少20個網站一起寫入的所有內容,但都沒有嘗試使其正常工作。我嘗試根據不同的教程安裝步驟,但沒有任何工作,因爲它應該。在小牛上使用Homebrew安裝MySQL的問題

我是這樣的:

brew update 
brew doctor 
brew upgrade 

brew install mysql 

啤酒將其安裝在/usr/local/Cellar/mysql/5.6.16 ...

我嘗試連接的釀造說:mysql -uroot

我做LaunchAgents目錄,自制的plist文件鏈接到它和發射控制:

mkdir -p ~/Library/LaunchAgents 
ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents 
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist 

之後,我試着和sudo mysql.server start啓動MySQL服務器,但我得到一個套接字錯誤

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) 

我試着以mysqld_safe &服務器,但我得到以下輸出:

[1] 69187 
Davids-MacBook-Air-5:~ davidsupan$ 140224 14:39:16 mysqld_safe Logging to  '/usr/local/var/mysql/Davids-MacBook-Air-5.local.err'. 
touch: /usr/local/var/mysql/Davids-MacBook-Air-5.local.err: Permission denied 
140224 14:39:16 mysqld_safe Starting mysqld daemon with databases from /usr/local/var/mysql 
/usr/local/bin/mysqld_safe: line 129: /usr/local/var/mysql/Davids-MacBook-Air-5.local.err: Permission denied 
/usr/local/bin/mysqld_safe: line 166: /usr/local/var/mysql/Davids-MacBook-Air-5.local.err: Permission denied 
140224 14:39:16 mysqld_safe mysqld from pid file /usr/local/var/mysql/Davids-MacBook-Air-5.local.pid ended 
/usr/local/bin/mysqld_safe: line 129: /usr/local/var/mysql/Davids-MacBook-Air-5.local.err: Permission denied 

以下命令似乎這樣的伎倆 須藤搭配chmod -R 755在/ usr /本地的/ var/mysql的 室射頻/usr/local/var/mysql/Davids-MacBook-Air-5.local.err

mysql.server restart 

和MySQL服務器成功地啓動

Shutting down MySQL 
.. SUCCESS! 
Starting MySQL 
. SUCCESS! 

其他時候,不管我做什麼,我不斷收到以下錯誤

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) 

有些建議做

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

但我沒有成功修復這個問題。

任何幫助,將不勝感激。我希望我詳細描述了這個問題。如果沒有,我會很樂意提供更多信息。

編輯:我嘗試mysqld的重新啓動,我得到更多的錯誤:

2014-02-25 12:35:54 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 
2014-02-25 12:35:54 34599 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/var/mysql/ is case insensitive 
2014-02-25 12:35:54 34599 [Note] Plugin 'FEDERATED' is disabled. 
2014-02-25 12:35:54 34599 [Note] InnoDB: Using atomics to ref count buffer pool pages 
2014-02-25 12:35:54 34599 [Note] InnoDB: The InnoDB memory heap is disabled 
2014-02-25 12:35:54 34599 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins 
2014-02-25 12:35:54 34599 [Note] InnoDB: Compressed tables use zlib 1.2.3 
2014-02-25 12:35:54 34599 [Note] InnoDB: Using CPU crc32 instructions 
2014-02-25 12:35:54 34599 [Note] InnoDB: Initializing buffer pool, size = 128.0M 
2014-02-25 12:35:54 34599 [Note] InnoDB: Completed initialization of buffer pool 
2014-02-25 12:35:54 34599 [ERROR] InnoDB: ./ibdata1 can't be opened in read-write mode 
2014-02-25 12:35:54 34599 [ERROR] InnoDB: The system tablespace must be writable! 
2014-02-25 12:35:54 34599 [ERROR] Plugin 'InnoDB' init function returned error. 
2014-02-25 12:35:54 34599 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed. 
mysqld: Too many arguments (first extra is 'restart'). 
Use --verbose --help to get a list of available options 
2014-02-25 12:35:54 34599 [ERROR] Aborting 

2014-02-25 12:35:54 34599 [Note] Binlog end 
2014-02-25 12:35:54 34599 [Note] Shutting down plugin 'partition' 
2014-02-25 12:35:54 34599 [Note] Shutting down plugin 'PERFORMANCE_SCHEMA' 
2014-02-25 12:35:54 34599 [Note] Shutting down plugin 'INNODB_SYS_DATAFILES' 
2014-02-25 12:35:54 34599 [Note] Shutting down plugin 'INNODB_SYS_TABLESPACES' 
2014-02-25 12:35:54 34599 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN_COLS' 
2014-02-25 12:35:54 34599 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN' 
2014-02-25 12:35:54 34599 [Note] Shutting down plugin 'INNODB_SYS_FIELDS' 
2014-02-25 12:35:54 34599 [Note] Shutting down plugin 'INNODB_SYS_COLUMNS' 
2014-02-25 12:35:54 34599 [Note] Shutting down plugin 'INNODB_SYS_INDEXES' 
2014-02-25 12:35:54 34599 [Note] Shutting down plugin 'INNODB_SYS_TABLESTATS' 
2014-02-25 12:35:54 34599 [Note] Shutting down plugin 'INNODB_SYS_TABLES' 
2014-02-25 12:35:54 34599 [Note] Shutting down plugin 'INNODB_FT_INDEX_TABLE' 
2014-02-25 12:35:54 34599 [Note] Shutting down plugin 'INNODB_FT_INDEX_CACHE' 
2014-02-25 12:35:54 34599 [Note] Shutting down plugin 'INNODB_FT_CONFIG' 
2014-02-25 12:35:54 34599 [Note] Shutting down plugin 'INNODB_FT_BEING_DELETED' 
2014-02-25 12:35:54 34599 [Note] Shutting down plugin 'INNODB_FT_DELETED' 
2014-02-25 12:35:54 34599 [Note] Shutting down plugin 'INNODB_FT_DEFAULT_STOPWORD' 
2014-02-25 12:35:54 34599 [Note] Shutting down plugin 'INNODB_METRICS' 
2014-02-25 12:35:54 34599 [Note] Shutting down plugin 'INNODB_BUFFER_POOL_STATS' 
2014-02-25 12:35:54 34599 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE_LRU' 
2014-02-25 12:35:54 34599 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE' 
2014-02-25 12:35:54 34599 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX_RESET' 
2014-02-25 12:35:54 34599 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX' 
2014-02-25 12:35:54 34599 [Note] Shutting down plugin 'INNODB_CMPMEM_RESET' 
2014-02-25 12:35:54 34599 [Note] Shutting down plugin 'INNODB_CMPMEM' 
2014-02-25 12:35:54 34599 [Note] Shutting down plugin 'INNODB_CMP_RESET' 
2014-02-25 12:35:54 34599 [Note] Shutting down plugin 'INNODB_CMP' 
2014-02-25 12:35:54 34599 [Note] Shutting down plugin 'INNODB_LOCK_WAITS' 
2014-02-25 12:35:54 34599 [Note] Shutting down plugin 'INNODB_LOCKS' 
2014-02-25 12:35:54 34599 [Note] Shutting down plugin 'INNODB_TRX' 
2014-02-25 12:35:54 34599 [Note] Shutting down plugin 'BLACKHOLE' 
2014-02-25 12:35:54 34599 [Note] Shutting down plugin 'ARCHIVE' 
2014-02-25 12:35:54 34599 [Note] Shutting down plugin 'MRG_MYISAM' 
2014-02-25 12:35:54 34599 [Note] Shutting down plugin 'MyISAM' 
2014-02-25 12:35:54 34599 [Note] Shutting down plugin 'MEMORY' 
2014-02-25 12:35:54 34599 [Note] Shutting down plugin 'CSV' 
2014-02-25 12:35:54 34599 [Note] Shutting down plugin 'sha256_password' 
2014-02-25 12:35:54 34599 [Note] Shutting down plugin 'mysql_old_password' 
2014-02-25 12:35:54 34599 [Note] Shutting down plugin 'mysql_native_password' 
2014-02-25 12:35:54 34599 [Note] Shutting down plugin 'binlog' 
2014-02-25 12:35:54 34599 [Note] mysqld: Shutdown complete 
+0

你能找到你的my.cnf文件嗎? – s2t2

+0

不,我無法在任何文件夾中找到my.cnf文件。 –

+0

你有沒有嘗試通過brew卸載mysql? http://stackoverflow.com/questions/4359131/brew-install-mysql-on-mac-os如果是這樣,你可能能夠然後使用brew重新安裝它 – s2t2

回答

1

昨天我們遇到了同樣的問題。 我的錯誤是在執行

sudo launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist 

在第一時間,但forgot卸載它。幾條線索:

  1. 過程mysqld_safe運行下root
  2. 過程mysql運行下_mysql
  3. 他們都updown連連。
  4. 錯誤文件/usr/local/var/mysql/*.err的所有者是_mysql
  5. 運行sudo launchctl list | grep mysql時,存在一個mysql服務

解決方法很簡單:

sudo launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist 
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist 

根本原因是,自制的MySQL的不假設在root下運行,至少看起來好像。

也許這不是你的問題,但我希望它會有所幫助。

1

這主要看起來像一個權限問題。這兩行很關鍵:

2014-02-25 12:35:54 34599 [ERROR] InnoDB: ./ibdata1 can't be opened in read-write mode 
2014-02-25 12:35:54 34599 [ERROR] InnoDB: The system tablespace must be writable! 

我可以看到你在mysql文件上設置了權限,但你也應該檢查所有權。用自制軟件做sudo chown -R david:staff /usr/local以及sudo chmod u+rwX /usr/local(一個比0755權限更好的選項)通常是安全的,而且在homebrew下的mysql應該像你一樣運行。

當你安裝,我建議你考慮使用Percona server版本的MySQL這是自制軟件也可作爲percona-server。你也可以考慮MariaDB--它們都是對於vanilla MySQL的替代品,並且具有一些優勢。