MySQL hell ... cannot connect to database / tmp / mysql.sock

Update: I EQUIPPED an old mysql process that is running and causes some confusion. Now I think that I only have a new version (5.1.40). BUT, this indicates an invalid data file. This points to the default installation data file, and I would like it to point to an existing data file in /var/mysql . Here is the part /etc/my.cnf

 # The following options will be passed to all MySQL clients [client] #password = your_password port = 3306 socket = /var/mysql/mysql.sock # Here follows entries for some specific programs # The MySQL server [mysqld] port = 3306 socket = /var/mysql/mysql.sock 

this points to the old mysql.sock. I can't seem to find the new MySQL installation in the directory tree?!? if only he is unclear somewhere.

Anyone help? Basically I installed a newer MySQL and now I need to run this new version with my existing data. And sort this thing out mysql.sock ....


I recently updated MySQL on Mac OS X Server, and I have a hell of a time connecting to it from a rails application. or sequentially from the command line, for that matter.

I am sure this is a clear mistake on my part, but I only have moderate command line experience, so hopefully someone can help ...

also due to the fact that my rails application can no longer connect. Failed to connect via /tmp/mysql.sock , but I'm not sure why it looks there, because there is no mysql.sock in / tmp, and I don't know what / where it should be ....

Edit: adding results from mysql_config --sockets

 $ mysql_config --sockets Usage: /usr/local/mysql/bin/mysql_config [OPTIONS] Options: --cflags [-I/usr/local/mysql/include -g -Os -arch ppc -fno-common -D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ -DIGNORE_SIGHUP_SIGQUIT -DDONT_DECLARE_CXA_PURE_VIRTUAL] --include [-I/usr/local/mysql/include] --libs [-arch ppc -L/usr/local/mysql/lib -lmysqlclient -lz -lm -lmygcc] --libs_r [-arch ppc -L/usr/local/mysql/lib -lmysqlclient_r -lz -lm -lmygcc] --plugindir [/usr/local/mysql/lib/plugin] --socket [/tmp/mysql.sock] --port [0] --version [5.1.40] --libmysqld-libs [-arch ppc -L/usr/local/mysql/lib -lmysqld -ldl -lz -lm -lmygcc] 

Edit2 which mysql_config

 $ which mysql_config /usr/local/mysql/bin/mysql_config 
+4
source share
3 answers

You are trying to use different sockets for server and client. Your Rails is trying to connect to /tmp/mysql.sock, MySQL is listening on /var/mysql/mysql.sock.

Normally, the MySQL configuration is stored in the /etc/my.cnf file, but in your ps on your output, I see that the socket path is set as a parameter. It really depends on the features of your system.

In any case, go to /etc/my.cnf and your database.yml and make sure mysql.sock is displayed in one file in one file.

+2
source

Not sure if this will completely solve your problem (you may need to fix the socket path as suggested by cababunga), but try 127.0.0.1 to bypass the socket connection and establish TCP one.

+1
source

The real_connect function in the Ruby MySQL module actually takes a bunch of parameters:

real_connect(host,user,password,db,port,socket,flags)

The one you need to change is the socket parameter. In my Python applications on Mac OS X, I have to set this socket /var/mysql/mysql.sock .

So mind you, this is not the host you need to change, it is a real socket. Is there a socket: parameter that you can use in your configuration?

So what can you do ...

Run the mysql_config --socket command at a command prompt in a terminal in OS X and it should return the value of the “socket” you need to use (possibly /var/mysql/mysql.sock ).

Then in the database.yml file, make sure you add the line:

socket: /var/mysql/mysql.sock

I basically came across this through Python on OS X and fixed it in a similar way, but I'm going to assume that Ruby will provide you with the same problem.

+1
source

All Articles