在Mac OS X v10.6 (Snow Leopard)上,启动MySQL会出现以下错误:

服务器退出,没有更新PID文件

文件my.cnf

[mysqld]
port            = 3306

socket          = /tmp/mysql.sock

skip-external-locking

key_buffer_size = 16K

pid-file=/var/run/mysqld/mysqld.pid

[mysqld_safe]

log-error=/var/log/mysqld.log

pid-file=/var/run/mysqld/mysqld.pid

当前回答

它可能与旧的MySQL进程有关。你得关掉它,重新启动。有时可能是由于MySQL配置文件中的冲突。尝试移动它并重新启动MySQL。

查看下面的URL了解更多详细信息。

http://linuxadministrator.pro/blog/?p=225

其他回答

我希望这对你有用。

在检查错误日志后,我发现了这个:

120309 17:42:49 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
120309 17:42:50 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/mysql/data/ is case insensitive
120309 17:42:50 [Warning] You need to use --log-bin to make --binlog-format work.
120309 17:42:50 [Note] Plugin 'FEDERATED' is disabled.
120309 17:42:50 InnoDB: The InnoDB memory heap is disabled
120309 17:42:50 InnoDB: Mutexes and rw_locks use GCC atomic builtins
120309 17:42:50 InnoDB: Compressed tables use zlib 1.2.3
120309 17:42:50 InnoDB: Initializing buffer pool, size = 16.0M
120309 17:42:50 InnoDB: Completed initialization of buffer pool
120309 17:42:50  InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
InnoDB: File name /usr/local/mysql/data/ib_logfile0
InnoDB: File operation call: 'open'.
InnoDB: Cannot continue operation.
120309 17:42:50 mysqld_safe mysqld from pid file /usr/local/mysql/data/lu1s.local.pid ended

为了解决这个问题,我给了整个mysql文件夹的所有权:

cd /usr/local
sudo chown mysql mysql
sudo chown mysql mysql-5.5.21-osx10.6-x86_64
sudo chown _mysql mysql
sudo chown _mysql mysql-5.5.21-osx10.6-x86_64

然后(你也可以做命令行),我应用权限(一旦我把所有权给_mysql和mysql用户),从文件夹/usr/local/mysql-5.5.21-osx10.6-x86_64的“获取信息”菜单中的所有附带的文件夹。你不需要把它传给别名,因为它只是一个别名。

文件夹的名称取决于MySQL的安装版本。

我使用

全新的MacBook Pro,搭载OS X v10.7.3操作系统。x(狮子) 通过OS X GCC安装程序

我使用Homebrew ('brew install MySQL ')安装MySQL。它安装了几个依赖项,然后安装了MySQL。

当我试着启动它时,

mysql.server start

Starting MySQL
.. ERROR! The server quit without updating PID file (/usr/local/var/mysql/west.local.pid).

我执行这个命令,

/usr/local/Cellar/mysql/5.5.25/scripts/mysql_install_db

和MySQL工作。

请注意,您需要从MySQL目录的顶层运行mysql_install_db(例如,usr/local/Cellar/ MySQL /5.5.25)。直接在/scripts目录中运行它并不能为它提供足够的上下文来运行它。

在Mac OS X v10.9 (Mavericks)上,这个脚本帮助了我:

bash <(curl -Ls http://git.io/eUx7rg)

然后我重置我的密码根据错误1045(28000):访问拒绝用户'root'@'localhost'(使用密码:YES)。

这是5.5版本的一个问题:

下面是my.cnf文件[mysqld]部分的示例:

skip-character-set-client-handshake
collation_server=utf8_unicode_ci
character_set_server=utf8

参考:10.3.2服务器字符集和排序规则

我的回答很不专业,我不理解。我用的是CentOS和通用版的MySQL…当我用root用户启动mysql时,我的问题用——user=root解决了:

/path/to/mysql/support-files/mysql.server start --user=root

如果你正在使用systemctl启动mysql。服务,您需要更改mysql。/etc/systemd/system/mysql.service中的服务文件:

.
.
.
ExecStart=/path/tp/mysql/support-files/mysql.server start --user=root
ExecStop=/path/to/mysql/support-files/mysql.server stop --user=root
.
.
.