我在使用Homebrew在Mavericks上安装MySQL时遇到了疯狂的问题。我知道有一个类似命名的主题,但我已经尝试了所有写在那里的所有内容以及至少20个网站但没有成功尝试使它工作。我尝试根据不同的教程安装步骤,但没有任何工作可以。
我是这样的:
brew update
brew doctor
brew upgrade
brew install mysql
Brew将其安装在/usr/local/Cellar/mysql/5.6.16 ...
我尝试连接,如Brew说: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
以下命令似乎可以解决问题 sudo chmod -R 755 / usr / local / var / mysql rm -Rf /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 restart ,我得到更多错误:
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 :(得分: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
权限更好的选项)通常是安全的,而且自制程序下的mysql应该像你一样运行。
在您安装时,我建议您考虑使用MySQL的Percona server版本,该版本也可以作为percona-server
在自制软件中使用。您还可以考虑使用MariaDB - 它们都是vanilla MySQL的替代品,并且具有一些优势。
答案 1 :(得分:1)
我们昨天遇到了同样的问题。 我的错误在于执行
sudo launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
第一次,但forgot
卸载它。几条线索:
mysqld_safe
在root
mysql
在_mysql
up
和down
。/usr/local/var/mysql/*.err
的所有者为_mysql
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
下运行,至少看起来如此。
也许这与你的问题不一样,但我希望它会有所帮助。