[MySQL] Install difficulties : Can't connect to local MySQL server through socket '/opt/local/var/run/mysql5/mysqld.sock'

sourceforge.rocks at xemaps.com sourceforge.rocks at xemaps.com
Tue Apr 1 02:58:29 PDT 2008


I thought I had previously responded to the list, but I must have  
responded only to Ryan.

On Mar 31, 2008, at 7:18 AM, Ryan Schmidt wrote:
>


> On Mar 31, 2008, at 05:45, sourceforge.rocks at xemaps.com wrote:

BTW, how do you get your name to show up instead of your email  
address?  I've got my name in the Optional Name field in my user  
profile, yet (as we see) my email address is showing up instead of my  
name.

>> I've installed and reinstalled MySQL with the following command line:
>>     $ sudo port install mysql5 +server
>>
>> Initially, I had trouble creating the initial mysql database  
>> because the /opt/local/temp directory did not exist (and therefore  
>> the /opt/local/temp/mysql5 directory did not exist).
>>
>> Creating these two directories, and making the mysql user the  
>> owner of /opt/local/temp/mysql5 allowed me to build the initial  
>> database, but sadly it had no data in any of the non-index tables.
>
> Where are you getting "/opt/local/temp" from? I've never heard of  
> that directory. Unless you've modified your my.cnf (in /opt/local/ 
> etc/mysql5/my.cnf or /etc/my.cnf or any of several other locations)  
> and deliberately pointed it at /opt/local/temp, your databases  
> should be stored in /opt/local/var/db/mysql5. Did you run  
> mysql_install_db to install the initial tables?

Error messages regarding not being able to create a file in /opt/ 
local/temp/mysql5 were in the /opt/local/var/db/mysql5/MyApple.err  
file.  The file names referenced lead me to believe that this was  
some sort of temporary file, not an entire database.

For the record, I have not created nor have I modified any .cnf file.

A reference to this error log was in the message that appeared when  
the "sudo -u mysql mysql_install_db5" command to create the initial  
tables failed.

I have no idea why the temp directory and its mysql5 directory did  
not exist after I installed mysql5.


>> I went ahead and unistalled mysql5 and reinstalled it, and now I  
>> get the following when I try to change the root password:
>>     $ mysqladmin -u root password 'newpass'
>>     mysqladmin: connect to server at 'localhost' failed    error:  
>> 'Can't connect to local MySQL server through socket '/opt/local/ 
>> var/run/mysql5/mysqld.sock' (2)'    Check that mysqld is running  
>> and that the socket: '/opt/local/var/run/mysql5/mysqld.sock' exists!
>>
>> I verified that mysqld is running through the Activity Monitor.
>>
>> Sure enough, /opt/local/var/run/mysql5/mysqld.sock does not  
>> exist.  In fact, mysqld.sock does not exist anywhere on my hard  
>> drive, a fact which I determined by:
>>     $ sudo find / -name "*.sock"
>
> If mysqld is running, there should be a socket somewhere so that  
> you can connect to the running server. Have you modified your  
> my.cnf to tell it to put the socket somewhere else? If so, look  
> there. The default location for the socket file in MacPorts mysql5  
> is /opt/local/var/run/mysql5. The default location for Apple and  
> mysql.com binary packages used to be /tmp but this was found to be  
> an insecure location. I believe it was changed to /var/mysql.
>
>
>> Elsewhere, I found an instruction to
>>     $ touch opt/local/var/run/mysql5/mysqld.sock
>>
>> This command creates an empty file of the correct name; however,  
>> when I tried to change the root password, I got:
>>     $ mysqladmin -u root password 'newpass'
>>     mysqladmin: connect to server at 'localhost' failed
>>     error: 'Can't connect to local MySQL server through socket '/ 
>> opt/local/var/run/mysql5/mysqld.sock' (38)'    Check that mysqld  
>> is running and that the socket: '/opt/local/var/run/mysql5/ 
>> mysqld.sock' exists!
>>
>> Note that only the error number changed.
>
> Where did you find that instruction? I don't think it's helpful...  
> There's no need to touch the socket file... mysqld creates it when  
> the server is running.

I found that instruction at http://samuraicoder.net/tags/mysql

> Does mysqld have permission to write to the /opt/local/var/run/ 
> mysql5 directory? (Is it owned by the mysql user and group?) Does  
> it have permission to write to your database directory?

I had not checked that before, but I did just now:
MyApple:~ me$ cd /opt/local/var/run
MyApple:/opt/local/var/run me$ sudo ls -l
total 0
drwxr-xr-x   3 mysql  mysql  102 Mar 31 06:37 mysql5

So, yep, the mysql user has write access to the /opt/local/var/run/ 
mysql5 directory which means that mysqld has write access.

>> When I stopped and restarted mysql5:
>>     $ sudo launchctl unload /Library/LaunchDaemons/ 
>> org.macports.mysql5.plist
>>     $ sudo launchctl load -w /Library/LaunchDaemons/ 
>> org.macports.mysql5.plist
>> I found that the mysqld.sock was deleted from opt/local/var/run/ 
>> mysql5/
>
> I'm not surprised that it would delete the socket file when  
> stopping the server; that's probably what it's supposed to do.

Which is another indication that mysqld has write access to the  
directory.

>> Does anyone have any ideas about what I'm supposed to do to get a  
>> properly functioning MySQL5 installation?
>>
>> Environment:
>>     MacPorts version 1.600.  I've done a selfupdate before  
>> attempting to install MySQL5
>>     Power Mac G4
>>     Mac OS X 10.4.11
>
> It should mostly "just work", and it does for me. I have 10.4.11 on  
> Intel.
>
> Can you check if there's anything in the log file in your database  
> directory? If the server had trouble starting (and therefore didn't  
> create the socket), the log should say why.

OK, good call.  There are a bunch of messages in the .err log file of  
this form:
     080331  6:37:08  InnoDB: Started; log sequence number 0 43655
     080331  6:37:08 [ERROR] Can't start server: Bind on TCP/IP port:  
Address already in use
     080331  6:37:08 [ERROR] Do you already have another mysqld  
server running on port: 3306 ?
     080331  6:37:08 [ERROR] Aborting

     080331  6:37:08  InnoDB: Starting shutdown...
     080331  6:37:10  InnoDB: Shutdown completed; log sequence number  
0 43655
     080331  6:37:10 [Note] /opt/local/libexec/mysqld: Shutdown complete

I just executed "sudo launchctl unload /Library/LaunchDaemons/ 
org.macports.mysql5.plist" again, and checked the Activity Monitor.   
The mysqld process is not stop.
I've killed the running mysqld and restarted mysql via launchctl.
Now, mysqld.sock exists!!!

So, I must have been mistaken when I said that mysqld had been  
stopped by the launchctl unload command.

Thanks for the help, and sorry to have taken up so much bandwidth.



More information about the macports-users mailing list