Hristo
Hristo

Reputation: 46477

Starting MySQL Error on Snow Leopard

ORIGINAL POST

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

I tried this:

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)

So I'm not sure what to do. When I first installed, the server was working but I went to the preference pane to try and stop it… and the same thing happened… I clicked the "Stop MysQL Server" button, it did some thinking, then nothing. So I restarted the computer and now I'm having the above problems and apparently, the mysql.sock file is not in /tmp/ anymore. It was there when I installed, and it is not there after I restarted the computer.

Any ideas?

UPDATE

This is my /etc/my.cnf file.

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

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

UPDATE 2

When setting up Apache, PHP, and MySQL, I followed these instructions: 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. But when my.cnf exists in /etc/, things don't work. The MySQL verion is:

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

UPDATE 3

mysql.err:

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.log:

/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

Upvotes: 11

Views: 24928

Answers (10)

Unreason
Unreason

Reputation: 12704

I think there is an error somewhere in your my.cnf file.

Try to take one of the stock my.cnf files or add options for user, pid-file, port, basedir, datadir, tmpdir under [mysqld] section (here's a quote of basic mysqld settings on linux machine, for OS X maybe this will help)

[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

Upvotes: 5

ryan
ryan

Reputation: 41

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

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

make sure your /usr/local/var/mysql and all subdirs is owned by current user!

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

if you want to startup mysql using the /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.

Upvotes: 4

Anurag
Anurag

Reputation: 29

First of all you have to unlock that pid process then. stop mysql by srvice mysql stop After that type this command ps-ef| grep mysql It will show two pid of sql. kill both by kill -9 pid 1 pid2 then start sql by service mysql start.

Upvotes: 2

carpeliam
carpeliam

Reputation: 6769

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 issue), but my root cause was a little different.

I had a working /etc/my.cnf file that abruptly stopped working, so I was confident the problem was not my config. It turned out that a subdirectory under /usr/local/var/mysql/ was owned by _mysql:staff, when it should have been owned by me. After running chown -R 'whoami' /usr/local/var/mysql/, all was right with the world.

Upvotes: 3

Scott Schulthess
Scott Schulthess

Reputation: 2923

If you installed view homebrew, try

unset TMPDIR
mysql_install_db

Upvotes: 0

Jed Schneider
Jed Schneider

Reputation: 14671

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

Upvotes: 16

Matt Bannert
Matt Bannert

Reputation: 28264

Try to install it as a part of MAMP . That will install a mysql server in a different location ( Applications/MAMP/mysql along with apache etc. Then you can just use the widget to start it. You can also monitor the activity with the acitivity monitor (Applications/utilities) . Besides:

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

and restarting does help often.

HTH

Upvotes: 0

sarnold
sarnold

Reputation: 104050

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.

My initial guess was that the mysqld doesn't have permission to update / delete its pidfile, and probably there is a left-over pidfile that needs to be removed by hand. But "great debugging justice" sounds too good to miss. :)

Upvotes: 0

Piskvor left the building
Piskvor left the building

Reputation: 92752

There seems to be an error message:

line 418: pidof: command not found

Do you have pidof installed? Its manpage says:

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?

Upvotes: 1

Aaron Butacov
Aaron Butacov

Reputation: 34347

The file is supposed to be recreated every time that MySQL is loaded, but sometimes permissions will get in the way. Try manually creating /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.

Upvotes: 3

Related Questions