代码之家  ›  专栏  ›  技术社区  ›  Hristo

雪豹启动mysql错误

  •  11
  • Hristo  · 技术社区  · 14 年前

    原帖

    I just erased and re-installed Snow Leopard. I installed MySQL 5.1.48 64-bit clean. I'm having issues with the MySQL server... when I boot the computer and log in, the server is not running. I tried to start it using the preference pane by clicking "Start MySQL Server", but all it did was highlight the button blue and think for like a minute, and then the button went back to normal and nothing happened.

    I then tried starting it from the terminal:

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

    so I checked the status:

    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/中了。它在我安装时就在那里,在我重新启动计算机后就不在那里了。

    有什么想法吗?

    更新

    这是我的 /etc/my.cnf 文件。

    [client]
    socket = /var/mysql/mysql.sock
    
    [mysqld]
    socket = /var/mysql/mysql.sock
    

    更新2

    在设置apache、php和mysql时,我遵循以下说明: http://superfancy.net/coding/php-mysql-apache-in-mac-osx-leopard/ Right now, if I remove the MySQL configuration file, things seem to work fine. 但是什么时候 my.cnf 存在于 /etc/ 情况不好。mysql版本是:

    Hristo$ mysql --version
    /usr/local/mysql/bin/mysql  Ver 14.14 Distrib 5.1.46, for apple-darwin9.8.0 (i386) using readline 5.1
    

    更新3

    MyQu.L.RR:

    100706 11:38:36 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
    100706 11:38:36 [Warning] '--log' is deprecated and will be removed in a future release. Please use ''--general_log'/'--general_log_file'' instead.
    100706 11:38:36 [Warning] '--log_slow_queries' is deprecated and will be removed in a future release. Please use ''--slow_query_log'/'--slow_query_log_file'' instead.
    100706 11:38:36 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/mysql/data/ is case insensitive
    100706 11:38:36 [Note] Plugin 'FEDERATED' is disabled.
    100706 11:38:36  InnoDB: Started; log sequence number 0 69987
    100706 11:38:36 [ERROR] Can't start server : Bind on unix socket: Permission denied
    100706 11:38:36 [ERROR] Do you already have another mysqld server running on socket: /var/mysql/mysql.sock ?
    100706 11:38:36 [ERROR] Aborting
    
    100706 11:38:36  InnoDB: Starting shutdown...
    100706 11:38:41  InnoDB: Shutdown completed; log sequence number 0 69987
    100706 11:38:41 [Note] /usr/local/mysql/bin/mysqld: Shutdown complete
    

    MySQL日志:

    /usr/local/mysql/bin/mysqld, Version: 5.1.46-log (MySQL Community Server (GPL)). started with:
    Tcp port: 0  Unix socket: /var/mysql/mysql.sock
    Time                 Id Command    Argument
    
    10 回复  |  直到 14 年前
        1
  •  5
  •   d3m    11 年前

    我想你的my.cnf文件中有错误。

    尝试使用一个stock my.cnf文件或在[mysqld]部分下为用户、pid文件、port、basedir、datadir、tmpdir添加选项(以下是Linux机器上基本mysqld设置的报价,对于OS X可能是这样) this 将有帮助)

    [mysqld]
    #
    # * Basic Settings
    #
    
    user        = mysql
    pid-file    = /var/run/mysqld/mysqld.pid
    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
    
        2
  •  16
  •   Jed Schneider    14 年前

    Install homebrew package manager with the quick install method http://github.com/mxcl/homebrew

    Then from terminal

    brew install mysql

    and follow the short list of directions that follow the installation

    to see the instructions again

    brew info mysql

        3
  •  4
  •   competent_tech    13 年前

    Just in case anyone else runs into this infuriating issue.....

    Homebrew install of mysql, snow leopard (most recent update)

    确定你的 /usr/local/var/mysql and all subdirs is owned by current user!

    sudo chown -R <user> /usr/local/var/mysql
    

    如果您想使用 /etc/my.cnf and you are specifying something like

    default-character-set=utf8
    

    your server will never start. I believe MySql 5.5.x has this set by default. Comment this line out in your my.cnf file and mysql.server start should do the trick.

        4
  •  3
  •   Aaron Butacov    14 年前

    每次加载MySQL时,都应该重新创建该文件,但有时权限会受到阻碍。尝试手动创建/tmp/mysql.sock

    On linux the command would be:

    sudo touch /tmp/mysqld.sock

    Then set the correct owner: sudo chown mysql:mysql /tmp/mysqld.sock

    I assume command line on a mac would be the same.

        5
  •  3
  •   carpeliam    13 年前

    I imagine that some of these other solutions will be appropriate for some other people, but I had all of these same symptoms (including the line 418: pidof: command not found

    我有一个工作 /etc/my.cnf 文件突然停止工作,所以我确信问题不是我的配置。结果发现下面有一个子目录 /usr/local/var/mysql/ was owned by _mysql:staff, when it should have been owned by me. 运行后 chown -R 'whoami' /usr/local/var/mysql/ , all was right with the world.

        6
  •  2
  •   Filip Radelic    13 年前

    First of all you have to unlock that pid process then. 停止MySQL srvice mysql stop 在那之后,键入这个命令 ps-ef| grep mysql It will show two pid of sql. 杀死双方 kill -9 pid 1 pid2 then start sql by service mysql start .

        7
  •  1
  •   Piskvor left the building Rohit Kumar    14 年前

    There seems to be an error message:

    line 418: pidof: command not found
    

    你有 pidof 安装? Its manpage 说:

    pidof is simply a (symbolic) link to the killall5 program, which should also be located in /sbin

    Perhaps the symlink doesn't exist or killall5 is not installed on your Mac OS?

        8
  •  0
  •   sarnold    14 年前

    http://dev.mysql.com/doc/refman/5.5/en/mysql-server.html

    Quoting David Tonhofer:

    And also add
    -----------
    echo "Manager PID file is $pid_file, Server PID file is $server_pid_file"
    -----------
    directly before the line 'case "$mode" in'
    for some great debugging justice.
    

    我最初的猜测是mysqld没有更新/删除其pid文件的权限,可能还有一个剩余的pid文件需要手动删除。但“伟大的调试正义”听起来太好了,不容错过。:)

        9
  •  0
  •   Matt Bannert    14 年前

    Try to install it as a part of MAMP . 这将在不同的位置(applications/mamp/mysql以及apache等)安装一个mysql服务器,然后您可以使用这个小部件来启动它。您还可以使用活动监视器(应用程序/实用程序)来监视活动。此外:

    Deleting: /Applications/MAMP/tmp/mysql/mysql.pid

    and restarting does help often.

    高温高压

        10
  •  0
  •   Scott Schulthess    13 年前

    If you installed view homebrew, try

    unset TMPDIR
    mysql_install_db