3

My socket file is located here:

/var/run/mysqld/mysqld.sock

When I do:

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 thinking_sphinx where my socket file is. How is this possible? This issue appeared after performing a hard reboot of my slice on Slicehost.

Tony
  • 18,776
  • 31
  • 129
  • 193

4 Answers4

5

EDITED to be (hopefully) clearer:

you can specify the mysql socket to be used in sphinx search's configuration file, sphinx.conf, via sql_sock:

sql_sock = /var/run/mysqld/mysqld.sock

(note that it depends on the sql_host setting whether this value will actually be used)

you can also use thinking_sphinx' configuration file, RAILS_ROOT/config/sphinx.yml, to set (overwrite) these values:

sql_sock: /var/run/mysqld/mysqld.sock
ax.
  • 58,560
  • 8
  • 81
  • 72
1

Some interesting code snippet from the edge sphinx, which states that sphinx requires TCP connections.

From thinking_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
James Boutcher
  • 2,593
  • 1
  • 25
  • 37
1

In the version 1.3.20 the socket path can be defined via database.yml, e.g

# database.yml
development:
  adapter: mysql
  database: app_name_development
  username: root
  password: 
  socket: /tmp/mysql.sock

Now, thinking-sphinx will use the socket path => /tmp/mysql.sock.

jpemberthy
  • 7,473
  • 8
  • 44
  • 52
0

The answer from ax does not work.

You can see from commit 49f467b25075666104a46b190139dd1bdbb1452f that someone's added support in SphinxHelper to set the socket. I haven't used this method, and don't have too much time to test it for you, so you're on your own with this method.

Also, curiously, in commit http://github.com/freelancing-god/thinking-sphinx/commit/a12dbd55ed9046faf6369a3d0aa452b75a31b5b6 it looks like they added support for sockets via your database.yml, however if you look at the current edge code, this seems to have been removed?

Short answer: symlink your actual mysqld.sock to the location sphinx is looking for it.