【问题标题】:How can I get MySQL to work on OSX?如何让 MySQL 在 OSX 上运行?
【发布时间】:2014-05-11 13:46:30
【问题描述】:

我通过自制软件在 OSX Mavericks 上安装了 MySQL。我收到以下错误消息:

ERROR! The server quit without updating PID file (/usr/local/var/mysql/jamess-air.config.pid)

每当我尝试mysql.server restart 时,我都会使用自制软件卸载并重新安装 MySQL。但是,每当我尝试运行服务器时,我仍然会收到相同的错误消息。

/usr/local/var/mysql/jamess-air.config.pid 不存在。我的 my.cnf 位于 /etc,如下所示:

#
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
# 
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html

# This will be passed to all mysql clients
# It has been reported that passwords should be enclosed with 
# ticks/quotes escpecially if they contain "#" chars...
# Remember to edit /etc/mysql/debian.cnf when changing 
# the socket location.
[client]
port        = 3306
#socket     = /var/run/mysqld/mysqld.sock

# Here is entries for some specific programs
# The following values assume you have at least 32M ram

# This was formally known as [safe_mysqld]. Both versions 
# are currently parsed.
[mysqld_safe]
#socket     = /var/run/mysqld/mysqld.sock
#nice       = 0

[mysqld]
#
# * Basic Settings
#

#
# * IMPORTANT
#   If you make changes to these settings and your system uses 
#   apparmor, you may also need to also adjust 
#   /etc/apparmor.d/usr.sbin.mysqld.
#

#user       = mysql
#socket     = /var/run/mysqld/mysqld.sock
port        = 3306
#basedir    = /usr
#datadir    = /var/lib/mysql
#tmpdir     = /tmp
skip-external-locking
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address        = 127.0.0.1
#
# * Fine Tuning
#
key_buffer          = 16M
max_allowed_packet  = 16M
thread_stack        = 192K
thread_cache_size   = 8
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam-recover         = BACKUP
#max_connections       = 100
#table_cache           = 64
#thread_concurrency    = 10
#
# * Query Cache Configuration
#
query_cache_limit   = 1M
query_cache_size    = 16M
#
# * Logging and Replication
#
# Both location gets rotated by the cronjob.
# Be aware that this log type is a performance killer.
# As of 5.1 you can enable the log at runtime!
#general_log_file        = /var/log/mysql/mysql.log
#general_log             = 1

log_error                = /var/log/mysql/error.log

# Here you can see queries with especially long duration
#log_slow_queries   = /var/log/mysql/mysql-slow.log
#long_query_time = 2
#log-queries-not-using-indexes
#
# The following can be used as easy to replay backup logs or 
# for replication.
# note: if you are setting up a replication slave, see 
#       README.Debian about other settings you may need 
#       to change.
#server-id          = 1
#log_bin            = /var/log/mysql/mysql-bin.log
expire_logs_days    = 10
max_binlog_size     = 100M
#binlog_do_db       = include_database_name
#binlog_ignore_db   = include_database_name
#
# * InnoDB
#
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
# Read the manual for more InnoDB related options. There are many!
#
# * Security Features
#
# Read the manual, too, if you want chroot!
# chroot = /var/lib/mysql/
#
# For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
#
# ssl-ca=/etc/mysql/cacert.pem
# ssl-cert=/etc/mysql/server-cert.pem
# ssl-key=/etc/mysql/server-key.pem

# Query Caching
query-cache-type = 1

# Default to InnoDB
default-storage-engine=innodb

[mysqldump]
quick
quote-names
max_allowed_packet  = 16M

[mysql]
#no-auto-rehash # faster start of mysql but no tab completition

[isamchk]
key_buffer      = 16M

这不是由 MySQL 的 Homebrew 安装提供的,所以我从 http://blog.joefallon.net/2013/10/install-mysql-on-mac-osx-using-homebrew/ 获取它

我在各个论坛上查看过有关此问题的帖子,但按照那里的步骤似乎并不能解决我的问题。这里发生了什么,我应该如何解决它?

根据@Cătălin Stan 下面的回答进行了编辑

【问题讨论】:

  • /usr/local/var/mysql/jamess-air.config.pid 存在吗?
  • 不,我应该将其创建为空文件还是有默认模板?
  • MySQL 服务器应该创建 pid 并将其写入该文件。 MySQL 用户是否对目录 /usr/local/var/mysql 有写权限
  • 您是否使用PATH=${PATH}:/usr/local/mysql/bin 或类似方法将mysql 路径添加到您的~/.bash_profile
  • @RamanShah: mysql 在 /usr/local/bin 是的,它包含在 $PATH 中

标签: mysql macos homebrew


【解决方案1】:

这通常是权限问题。

  1. 检查您的 my.cnf 文件以查看用户 mysqld 在下运行
  2. 检查mysql需要使用的路径的权限
  3. mysql 错误日志中的“tail -f”(通常在数据目录中找到)希望这会产生一些信息。

在旁注中,Myslq 自己有一个打包好的 OSX 安装程序可供下载。它甚至带有一个首选项窗格,以便您可以从那里开始和停止它。

希望这会有所帮助。

【讨论】:

  • 谢谢!我已经编辑了这个问题以提供更多信息。 my.cnf 是默认的,我应该为用户设置什么,你觉得呢?
  • 通常,在 unix/linux 机器上,我们会创建一个名为 ... mysql 的用户和组,并在该用户和组下运行守护程序。但是,如果您在 OS X 上达到了这一点,则表明您可能应该采取另一条路线。
  • 因此,我真的,真的建议你试试 MySql 的包。它会为你做这一切,它会运行。 :) 这是链接:http://dev.mysql.com/downloads/file.php?id=451508。这将下载 mysql 5.7 的 64 位 dmg 安装程序。一定要清理安装的自制软件。以防万一。
  • 谢谢,@Cătălin Stan - 最后证明是一个不同的烫发问题(见上文)。我想我会暂时坚持使用 Homebrew,但感谢您的建议 :)
【解决方案2】:

好的,这似乎是一个权限问题,但与@Cătălin Stan 所描述的不同。

我(错误地,据我现在理解)将 brew 与 sudo 一起使用,可能是因为当我尝试 brew install 任何东西时遇到了权限问题。但是,似乎 brew 应该在没有 sudo 的情况下运行。这样做最终导致我

Homebrew install issues

并提醒我,我可能有影响 brew 的许可和/或所有权问题。运行sudo chown -Rwhoami/Library/Caches/Homebrew/ 修复了这些问题,MySQL 安装完美。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-07-09
    • 1970-01-01
    • 1970-01-01
    • 2011-01-07
    • 2010-09-05
    • 1970-01-01
    • 2017-01-15
    相关资源
    最近更新 更多