How to specify the location of the MySQL sock file for sphinx thinking?
My socket file is located here:
/var/run/mysqld/mysqld.sock
When I do this:
rake thinking_sphinx:start
I get:
rake aborted!
Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
I want to tell think_sphinx where my socket file is located. How is this possible? This issue appeared after doing a hard reload of my snippet on Slicehost.
source to share
EDITED is (I hope) clearer:
you can specify the mysql socket to be used in the sphinx lookup config file sphinx.conf
via sql_sock
:
sql_sock = /var/run/mysqld/mysqld.sock
(note that this depends on sql_host
whether or not this value will actually be used)
you can also use the think_sphinx config file RAILS_ROOT/config/sphinx.yml
to set (overwrite) these values:
sql_sock: /var/run/mysqld/mysqld.sock
source to share
Some interesting code snippets from edge sphinx which says sphinx requires TCP connections.
From think_sphinx / configuration.rb:
def connection
# If you use localhost, MySQL insists on a socket connection, but Sphinx
# requires a TCP connection. Using 127.0.0.1 fixes that.
address = searchd.address || '127.0.0.1'
address = '127.0.0.1' if address == 'localhost'
Mysql2::Client.new(
:host => address,
:port => searchd.mysql41,
:flags => Mysql2::Client::MULTI_STATEMENTS
)
end
source to share
The answer from the ax doesn't work.
You can see from commit 49f467b25075666104a46b190139dd1bdbb1452f that someone added support in the SphinxHelper for socket setup. I haven't used this method and don't have too much time to test it for you, so you are using this method on your own.
Also, curiously, in commit http://github.com/freelancing-god/thinking-sphinx/commit/a12dbd55ed9046faf6369a3d0aa452b75a31b5b6 it looks like they added socket support via your database.yml, however if you look at the current edge code it seems remote?
Short answer: symlink your actual mysqld.sock to the location sphinx is looking for.
source to share