Problems installing MySQL with Homebrew on Mavericks
homebrew, mysql, osx-mavericks, sockets
Solution
We met the same problem yesterday. My mistake was executing
sudo launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
at the first time, but `forgot` to unload it. Several clues:
- a process `mysqld_safe` runs under `root`
- a process `mysql` runs under `_mysql`
- they both `up` and `down` again and again.
- the owner of error file `/usr/local/var/mysql/*.err` is `_mysql`
- when run `sudo launchctl list | grep mysql`, a mysql service exists
The solution is simple:
sudo launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
The root reason is that, homebrew's mysql is not assumed to be run under `root`, at least it seems.
Maybe it is not the same problem as yours, but I wish it would help.
Problem
I'm having insane problems installing MySQL with Homebrew on Mavericks. I know there is a similarly named topic, but I have tried everything written there along with at least 20 sites with no success trying to make it work. I tried installing with steps according to different tutorials but nothing works as it should. I go like this: ``` brew update brew doctor brew upgrade brew install mysql ``` Brew installs it in /usr/local/Cellar/mysql/5.6.16 ... I try connecting as Brew says: `mysql -uroot` I make the LaunchAgents directory, link the homebrew plist file to it and launch controls: ``` mkdir -p ~/Library/LaunchAgents ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist ``` after that I try and start the mysql server with `sudo mysql.server start` but I get a socket error ``` ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) ``` I try starting the server with `mysqld_safe &` but I get the following output: ``` [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 ``` The following commands seem to do the trick sudo chmod -R 755 /usr/local/var/mysql rm -Rf /usr/local/var/mysql/Davids-MacBook-Air-5.local.err ``` mysql.server restart ``` and the mysql server succesfully starts ``` Shutting down MySQL .. SUCCESS! Starting MySQL . SUCCESS! ``` Other times, no matter what I do, I keep getting the following error ``` ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) ``` Some pages suggest doing ``` unset TMPDIR mysql_install_db --verbose --user='whoami' \\ --basedir="$(brew --prefix mysql)" \\ --datadir=/usr/local/var/mysql --tmpdir=/tmp ``` but I have no success mending this problem. Any help would be appreciated. I hope I described the problem detailed enough. If not, I would be glad to provide more information. EDIT: I try mysqld restart and I get even more errors: ``` 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 ```