views:

78

answers:

4

This is a recent problem... MySQL was working and a couple of days ago I must have done something. I deleted MySQL and tried reinstalling using the .dmg file. The mysql.sock file never gets created and I get the following error messages:

Hristo$ mysql
Enter password: 
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/mysql/mysql.sock' (2)

I also tried stopping Apache and installing but Apache gave me an error... I don't know if this is good or bad:

Hristo$ sudo apachectl stop
launchctl: Error unloading: org.apache.httpd

I tried the MacPorts installation as well but the socket file still didn't get created. I don't really know what to do and I don't want to reinstall Snow Leopard and start from scratch :/

I also tried installing the 32-bit version and same deal. No luck.

Finally... I tried doing the source installation but when I get to the configuration step, I get the following error:

-bash: ./configure: No such file or directory

The file is "mysql-5.1.47-osx10.6-x86_64.tar.gz" so I think it is the proper file for source installation and yes I have a 64 bit system. I don't know what to do anymore.

Any ideas?

Thanks, Hristo

Edit: This is what I get after installing MySQL using the .dmg package... I don't really know what it means? So is MySQL running or not? I think not?

Hristo$ ps auxw | grep mysql Hristo 1599 0.2 0.0 2425520 96 s000 R+ 3:39AM 0:00.00 grep mysql

A: 

Hi,

I would recommend you to go thru the error_log files and see if there is anything there to help you with what is going on...

About the mysql, verify if the data folder exist, has the right user and permissions before starting it, there is also scripts/mysql_install_db.

Usually when the data folder has no permission, dont exist or something alike, mysql won't create the sock and in most cases won't start.

This may also help you: http://hivelogic.com/articles/installing-mysql-on-mac-os-x

I am not much a MAC user ...

Prix
What is this 'data folder' you're talking about? Where should I look for it?
Hristo
When you run mysql_install_db it initializes the MySQL data directory and creates the system tables that it contains, if they do not exist. I am not sure on the dir structure in MAC but it usually is at /var/lib/mysql or /opt/mysql/mysql/data but it also depends if you have done any personalized setup.
Prix
+1  A: 

The socket location is defined in my.cnf

Both the mysql client and server must use the same socket path in order to connect. Make sure that both the mysql client and server use the same configuration file or change the configuration so that they use the same socket.

You may also do which mysql to ensure you're using the right mysql binary.

Alexandre Jasmin
+1  A: 

Things to check:

  1. Is mysql even running? ps auxw | grep mysql. If nothing shows up, it's not running, which explains the lack of a socket
  2. If apache wasn't running, then it'd throw an error trying to stop it. ps auxw|grep httpd should show a number of httpd child processes if Apache is running. If it can't start up, it will explain why in the the error_log, the location of which you can get from the httpd.conf file.
  3. The filename of the mysql .tar.gz you downloaded suggests that it's actually a pre-compiled binary version. As such there wouldn't be a 'configure' script. mysql.com doesn't have a MacOS specific source file. There's just a generic .tar.gz here (select 'Source Code' in the dropdown box) for non-Linux systems..
Marc B
Thanks... I never actually saw the "Source Code" option in the dropdown... I'm trying the installation now!
Hristo
./configure file exists now and its 'making'
Hristo
got to the point to set the root password... but I still get the error about the socket. Hristo$ mysqladmin -u root password "newpassword"/usr/local/mysql/bin/mysqladmin: connect to server at 'localhost' failederror: 'Can't connect to local MySQL server through socket '/var/mysql/mysql.sock' (2)'Check that mysqld is running and that the socket: '/var/mysql/mysql.sock' exists!
Hristo
You probably want to `ps auxw | grep mysqld` more specifically.
Alexandre Jasmin
+1  A: 

Finally figured it out... I tried pretty much everything but it all came down to deleting every instance of MySQL and I was missing something when I was deleting everything. To completely uninstall MySQL:

sudo rm /usr/local/mysql
sudo rm -rf /usr/local/mysql*
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/My*
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*
sudo rm /etc/my.cnf

Also, you have to remove the line “MYSQLCOM=-YES-” from the /etc/hostconfig file. My problem was that I never removed the /etc/my.cnf file! If you don't delete this file, apparently you get socket issues! So that was the culprit. Then I just did a regular install from the .dmg file from the MySQL website and everything works :)

Thanks everyone for their suggestions and time!

Hristo