使用Homebrew在小牛上安装MySQL的问题

时间:2021-07-09 06:07:01

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.

我在小牛队用Homebrew安装MySQL时遇到了疯狂的问题。我知道有一个类似命名的主题,但我已尝试在那里写的所有内容以及至少20个网站但没有成功尝试使其工作。我尝试根据不同的教程安装步骤,但没有任何工作应该。

I go like this:

我是这样的:

brew update
brew doctor
brew upgrade

brew install mysql

Brew installs it in /usr/local/Cellar/mysql/5.6.16 ...

Brew将它安装在/usr/local/Cellar/mysql/5.6.16中......

I try connecting as Brew says: mysql -uroot

我尝试连接,因为Brew说:mysql -uroot

I make the LaunchAgents directory, link the homebrew plist file to it and launch controls:

我创建LaunchAgents目录,将自制的plist文件链接到它并启动控件:

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

之后我尝试用sudo mysql.server启动启动mysql服务器,但是我收到套接字错误

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:

我尝试用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

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

以下命令似乎可以解决问题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

并成功启动mysql服务器

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:

编辑:我尝试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

2 个解决方案

#1


1  

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:

在第一次,但忘了卸下它。几条线索:

  1. a process mysqld_safe runs under root
  2. 一个进程mysqld_safe在root下运行

  3. a process mysql runs under _mysql
  4. 一个进程mysql在_mysql下运行

  5. they both up and down again and again.
  6. 他们一次又一次地上下起伏。

  7. the owner of error file /usr/local/var/mysql/*.err is _mysql
  8. 错误文件/usr/local/var/mysql/*.err的所有者是_mysql

  9. when run sudo launchctl list | grep mysql, a mysql service exists
  10. 当运行sudo launchctl list | grep mysql,存在一个mysql服务

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.

根本原因在于,自制软件的mysql不会被认为是在root下运行,至少看起来如此。

Maybe it is not the same problem as yours, but I wish it would help.

也许这与你的问题不一样,但我希望它会有所帮助。

#2


1  

This mainly looks like a permissions problem. These two lines are critical:

这主要看起来像权限问题。这两行非常重要:

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!

I can see you set permissions on the mysql files, but you should probably check ownership too. With homebrew it's generally safe to do sudo chown -R david:staff /usr/local as well as sudo chmod u+rwX /usr/local (a better option than 0755 permissions), and mysql under homebrew should be running as you.

我可以看到你设置mysql文件的权限,但你也应该检查所有权。使用自制程序,通常可以安全地执行sudo chown -R david:staff / usr / local以及sudo chmod u + rwX / usr / local(比0755权限更好的选项),而homebrew下的mysql应该像你一样运行。

While you're installing, I'd recommend you look into using the Percona server version of MySQL which is also available in homebrew as percona-server. You could also consider MariaDB - they are both drop-in replacements for vanilla MySQL and have some advantages.

在您安装时,我建议您考虑使用Percona服务器版本的MySQL,也可以在homebrew中作为percona-server使用。您还可以考虑MariaDB - 它们都是vanilla MySQL的替代品,并且具有一些优势。

#1


1  

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:

在第一次,但忘了卸下它。几条线索:

  1. a process mysqld_safe runs under root
  2. 一个进程mysqld_safe在root下运行

  3. a process mysql runs under _mysql
  4. 一个进程mysql在_mysql下运行

  5. they both up and down again and again.
  6. 他们一次又一次地上下起伏。

  7. the owner of error file /usr/local/var/mysql/*.err is _mysql
  8. 错误文件/usr/local/var/mysql/*.err的所有者是_mysql

  9. when run sudo launchctl list | grep mysql, a mysql service exists
  10. 当运行sudo launchctl list | grep mysql,存在一个mysql服务

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.

根本原因在于,自制软件的mysql不会被认为是在root下运行,至少看起来如此。

Maybe it is not the same problem as yours, but I wish it would help.

也许这与你的问题不一样,但我希望它会有所帮助。

#2


1  

This mainly looks like a permissions problem. These two lines are critical:

这主要看起来像权限问题。这两行非常重要:

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!

I can see you set permissions on the mysql files, but you should probably check ownership too. With homebrew it's generally safe to do sudo chown -R david:staff /usr/local as well as sudo chmod u+rwX /usr/local (a better option than 0755 permissions), and mysql under homebrew should be running as you.

我可以看到你设置mysql文件的权限,但你也应该检查所有权。使用自制程序,通常可以安全地执行sudo chown -R david:staff / usr / local以及sudo chmod u + rwX / usr / local(比0755权限更好的选项),而homebrew下的mysql应该像你一样运行。

While you're installing, I'd recommend you look into using the Percona server version of MySQL which is also available in homebrew as percona-server. You could also consider MariaDB - they are both drop-in replacements for vanilla MySQL and have some advantages.

在您安装时,我建议您考虑使用Percona服务器版本的MySQL,也可以在homebrew中作为percona-server使用。您还可以考虑MariaDB - 它们都是vanilla MySQL的替代品,并且具有一些优势。