Snow Leopard 上的 MySQL 问题

Snow Leopard 上的 MySQL 问题

我刚刚删除并重新安装了 Snow Leopard。我安装了干净的 MySQL 5.1.48 64 位。我遇到了 MySQL 服务器问题...当我启动计算机并登录时,服务器没有运行。我尝试使用偏好设置窗格通过单击“启动 MySQL 服务器”来启动它,但它所做的只是将按钮突出显示为蓝色并思考了大约一分钟,然后按钮恢复正常,什么也没发生。

然后我尝试从终端启动它:

    Hristo$ sudo /usr/local/mysql/support-files/mysql.server start
    Starting MySQL
    ....................................................................................................
    ERROR! Manager of pid-file quit without updating file.

所以我检查了状态:

Hristo$ sudo /usr/local/mysql/support-files/mysql.server status
Password:
/usr/local/mysql/support-files/mysql.server: line 418: pidof: command not found
 ERROR! MySQL is not running

我尝试过这个:

Hristo$ /usr/local/mysql/bin/mysql -u root -p
Enter password: 
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

所以我不知道该怎么办。今天早些时候,服务器还在运行,但我进入首选项窗格尝试停止它……结果发生了同样的事情……我点击了“停止 MySQL 服务器”按钮,它思考了一会儿,然后什么也没做。所以我重启了电脑,现在我遇到了上述问题,显然,mysql.sock 文件不再位于 /tmp/ 中……它今天早些时候还在。

有任何想法吗?

谢谢,Hristo

更新2:错误日志文件:

100701 13:27:03 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
100701 13:27:03 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/mysql/data/ is case insensitive
100701 13:27:03 [Note] Plugin 'FEDERATED' is disabled.
InnoDB: Unable to lock ./ibdata1, error: 35
InnoDB: Check that you do not already have another mysqld process
InnoDB: using the same InnoDB data or log files.
100701 13:27:03  InnoDB: Retrying to lock the first data file
InnoDB: Unable to lock ./ibdata1, error: 35
InnoDB: Check that you do not already have another mysqld process
InnoDB: using the same InnoDB data or log files.
InnoDB: Unable to lock ./ibdata1, error: 35

这种情况重复了一段时间然后......

InnoDB: using the same InnoDB data or log files.
InnoDB: Unable to lock ./ibdata1, error: 35
InnoDB: Check that you do not already have another mysqld process
InnoDB: using the same InnoDB data or log files.
100701 13:28:43  InnoDB: Unable to open the first data file
InnoDB: Error in opening ./ibdata1
100701 13:28:43  InnoDB: Operating system error number 35 in a file operation.
InnoDB: Error number 35 means 'Resource temporarily unavailable'.
InnoDB: Some operating system error numbers are described at
InnoDB: http://dev.mysql.com/doc/refman/5.1/en/operating-system-error-codes.html
InnoDB: Could not open or create data files.
InnoDB: If you tried to add new data files, and it failed here,
InnoDB: you should now edit innodb_data_file_path in my.cnf back
InnoDB: to what it was, and remove the new ibdata files InnoDB created
InnoDB: in this failed attempt. InnoDB only wrote those files full of
InnoDB: zeros, but did not yet use them in any way. But be careful: do not
InnoDB: remove old data files which contain your precious data!
100701 13:28:43 [ERROR] Plugin 'InnoDB' init function returned error.
100701 13:28:43 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
100701 13:28:43 [ERROR] Can't start server: Bind on TCP/IP port: Address already in use
100701 13:28:43 [ERROR] Do you already have another mysqld server running on port: 3306 ?
100701 13:28:43 [ERROR] Aborting

100701 13:28:43 [Note] /usr/local/mysql/bin/mysqld: Shutdown complete

100701 13:28:43 mysqld_safe mysqld from pid file /usr/local/mysql/data/pid_file.pid ended

更新:尝试使用以下命令启动 MySQLsudo sh -x

Hristo$ sudo sh -x /usr/local/mysql/support-files/mysql.server start
+ basedir=
+ datadir=
+ service_startup_timeout=900
+ pid_file=
+ server_pid_file=
+ use_mysqld_safe=1
+ user=mysql
+ test -z ''
+ basedir=/usr/local/mysql
+ bindir=./bin
+ test -z ''
+ datadir=/usr/local/mysql/data
+ sbindir=./bin
+ libexecdir=./bin
+ datadir_set=
+ lsb_functions=/lib/lsb/init-functions
+ test -f /lib/lsb/init-functions
+ PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/mysql/bin
+ export PATH
+ mode=start
+ shift
+ other_args=
+ case `echo "testing\c"`,`echo -n testing` in
++ echo 'testing\c'
++ echo -n testing
+ echo_n=
+ echo_c='\c'
+ test -x ./bin/my_print_defaults
+ print_defaults=./bin/my_print_defaults
+ extra_args=
+ test -r /usr/local/mysql/my.cnf
+ test -r /usr/local/mysql/data/my.cnf
++ ./bin/my_print_defaults mysqld server mysql_server mysql.server
+ parse_server_arguments
++ ./bin/my_print_defaults manager
+ parse_manager_arguments
+ test -z ''
++ /bin/hostname
+ pid_file=/usr/local/mysql/data/mysqlmanager-pid_file.pid
+ test -z ''
++ /bin/hostname
+ server_pid_file=/usr/local/mysql/data/pid_file.pid
+ case "$mode" in
+ cd /usr/local/mysql
+ manager=./bin/mysqlmanager
+ test -x ./bin/mysqlmanager
+ manager=./bin/mysqlmanager
+ echo 'Starting MySQL'
Starting MySQL
+ test -x ./bin/mysqlmanager -a 1 = 0
+ test -x ./bin/mysqld_safe
+ pid_file=/usr/local/mysql/data/pid_file.pid
+ wait_for_pid created 23653
+ verb=created
+ manager_pid=23653
+ i=0
+ avoid_race_condition='by checking again'
+ test 0 -ne 900
+ case "$verb" in
+ test -s /usr/local/mysql/data/pid_file.pid
+ test -n 23653
+ kill -0 23653
+ :
+ echo '.\c'
.+ ./bin/mysqld_safe --datadir=/usr/local/mysql/data --pid-file=/usr/local/mysql/data/pid_file.pid
++ expr 0 + 1
+ i=1
+ sleep 1
+ test 1 -ne 900
+ case "$verb" in
+ test -s /usr/local/mysql/data/pid_file.pid
+ test -n 23653
+ kill -0 23653
+ :
+ echo '.\c'
.++ expr 1 + 1
+ i=2
+ sleep 1
+ test 2 -ne 900
+ case "$verb" in
+ test -s /usr/local/mysql/data/pid_file.pid
+ test -n 23653
+ kill -0 23653
+ :

这样重复了很长时间...

+ echo '.\c'
.++ expr 97 + 1
+ i=98
+ sleep 1
+ test 98 -ne 900
+ case "$verb" in
+ test -s /usr/local/mysql/data/pid_file.pid
+ test -n 23653
+ kill -0 23653
+ :
+ echo '.\c'
.++ expr 98 + 1
+ i=99
+ sleep 1
+ test 99 -ne 900
+ case "$verb" in
+ test -s /usr/local/mysql/data/pid_file.pid
+ test -n 23653
+ kill -0 23653
+ :
+ echo '.\c'
.++ expr 99 + 1
+ i=100
+ sleep 1
+ test 100 -ne 900
+ case "$verb" in
+ test -s /usr/local/mysql/data/pid_file.pid
+ test -n 23653
+ kill -0 23653
+ test -n 'by checking again'
+ avoid_race_condition=
+ continue
+ test 100 -ne 900
+ case "$verb" in
+ test -s /usr/local/mysql/data/pid_file.pid
+ test -n 23653
+ kill -0 23653
+ test -n ''
+ log_failure_msg 'Manager of pid-file quit without updating file.'
+ echo ' ERROR! Manager of pid-file quit without updating file.'
 ERROR! Manager of pid-file quit without updating file.
+ return 1
+ return_value=1
+ test -w /var/lock/subsys
+ exit 1

答案1

您是否检查了要创建 PID 文件的目录(/var/run 或其他)的权限?

也可能是因为 my.cnf 中的选项有误。尝试在不使用 my.cnf 的情况下启动 MySQL(重命名)或注释掉除绝对必要的选项之外的所有内容。

答案2

原因可能有很多种,您的问题中提供的信息不足以让我们确定问题的原因。

尤其:

您是如何安装 MySQL 的?您是否使用了软件包?如果是,是哪一个?还是您是从源代码构建的?

以下是一些建议:

如果您将启动命令更改为:

sudo sh -x /usr/local/mysql/support-files/mysql.server start

您将看到脚本执行的每个命令,这将帮助您(我们)了解哪里出了问题。

在我的 OSX 10.5 安装中,/usr/local/mysql 下的所有内容均归 root:wheel 所有除了/usr/local/mysql/data 即 _mysql:wheel。这可能是最常见的 mysql 启动问题。

错误日志可能会提供信息,可能位于 /usr/local/mysql/data/HOSTNAME.err。

这应该足以让您自己解决问题;如果不能,请回答我的问题并发布您的日志,我们可以从那里开始。

答案3

如果您从 DMG 安装,则会有一个随附的启动脚本,您双击了它吗?

好的,该脚本在 /Library/StartupItems/MySQLCOM 中安装了一些东西

不要执行 mysql.server,而是尝试使用它来启动/停止。我知道它所做的就是调用 mysql.server,但我想知道是否一切都安装正确。以下内容是从 DMG 上的 README 复制粘贴的。

如果您已经安装了启动项,请使用以下命令:

 shell> sudo /Library/StartupItems/MySQLCOM/MySQLCOM start
 (ENTER YOUR PASSWORD, IF NECESSARY)
 (PRESS CONTROL-D OR ENTER "EXIT" TO EXIT THE SHELL)

如果不使用启动项,请输入以下命令序列:

 shell> cd /usr/local/mysql
 shell> sudo ./bin/mysqld_safe
 (ENTER YOUR PASSWORD, IF NECESSARY)
 (PRESS CONTROL-Z)
 shell> bg
 (PRESS CONTROL-D OR ENTER "EXIT" TO EXIT THE SHELL)

相关内容