ERROR: index 'main1': sql_connect: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) (DSN=mysql://piler:***@localhost:3306/piler).

Issue #1114 resolved
Dale Storrie created an issue

Hi, I am sorry if this is the incorrect place to ask for help but I cant find any community support or irc channel to join.

I have installed all my prerequisites and get to the point where I run “make postinstall” which asks all the questions etc and then asks to make the system changes. When I say yes I get the below error:

Continue and modify system? [Y/N] [N] y

Creating mysql database... Done.
Writing sphinx configuration... Done.
Sphinx 3.3.1 (commit b72d67b)
Initializing sphinx indices... Sphinx 3.3.1 (commit b72d67b)
Copyright (c) 2001-2020, Andrew Aksyonoff
Copyright (c) 2008-2016, Sphinx Technologies Inc (http://sphinxsearch.com))

using config file '/usr/local/etc/piler/sphinx.conf'...
indexing index 'main1'...
ERROR: index 'main1': sql_connect: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) (DSN=mysql://piler:@localhost:3306/piler).
total 0 docs, 0.0 Kb
total 0.0 sec, 0.0 Kb/sec, 0 docs/sec
indexing index 'main2'...
ERROR: index 'main2': sql_connect: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) (DSN=mysql://piler:@localhost:3306/piler).
total 0 docs, 0.0 Kb
total 0.0 sec, 0.0 Kb/sec, 0 docs/sec
indexing index 'main3'...
ERROR: index 'main3': sql_connect: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) (DSN=mysql://piler:@localhost:3306/piler).
total 0 docs, 0.0 Kb
total 0.0 sec, 0.0 Kb/sec, 0 docs/sec
indexing index 'main4'...
ERROR: index 'main4': sql_connect: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) (DSN=mysql://piler:@localhost:3306/piler).
total 0 docs, 0.0 Kb
total 0.0 sec, 0.0 Kb/sec, 0 docs/sec
indexing index 'dailydelta1'...
ERROR: index 'dailydelta1': sql_connect: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) (DSN=mysql://piler:@localhost:3306/piler).
total 0 docs, 0.0 Kb
total 0.0 sec, 0.0 Kb/sec, 0 docs/sec
indexing index 'delta1'...
ERROR: index 'delta1': sql_connect: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) (DSN=mysql://piler:@localhost:3306/piler).
total 0 docs, 0.0 Kb
total 0.0 sec, 0.0 Kb/sec, 0 docs/sec
indexing index 'tag1'...
ERROR: index 'tag1': sql_connect: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) (DSN=mysql://piler:@localhost:3306/piler).
total 0 docs, 0.0 Kb
total 0.0 sec, 0.0 Kb/sec, 0 docs/sec
indexing index 'note1'...
ERROR: index 'note1': sql_connect: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) (DSN=mysql://piler:@localhost:3306/piler).
total 0 docs, 0.0 Kb
total 0.0 sec, 0.0 Kb/sec, 0 docs/sec
Makefile:126: recipe for target 'postinstall' failed
make: *** [postinstall] Error 1

I have checked on Google and people say this is because MySQL isn’t running but I have checked and it defiantly is.

Please can anyone advise what to check/where to go for support?

Thank you in advance.

Comments (6)

  1. Janos SUTO repo owner

    Check sphinx.conf and verify that you can connect with the sql_* parameters' values. Assuming that you have a local mysql daemon, you shouldn’t even specify the socket, since sphinx should be able to figure out from the mysql library.

  2. Dale Storrie reporter

    Please could you give a little more detail as to what to look for? I have looked right through the sphinx.conf and it all looks fine. How do I check if I can connect with the sql_* parameters?

    Even if I simply try to run rc.searchd I get the below:

    starting searchd . . .
    Sphinx 3.3.1 (commit b72d67b)
    Copyright (c) 2001-2020, Andrew Aksyonoff
    Copyright (c) 2008-2016, Sphinx Technologies Inc (http://sphinxsearch.com))

    using config file '/usr/local/etc/piler/sphinx.conf'...
    listening on 127.0.0.1:9312
    listening on 127.0.0.1:9306
    precaching index 'main1'
    WARNING: index 'main1': prealloc: failed to open /var/piler/sphinx/main1.sph: No such file or directory; NOT SERVING
    precaching index 'main2'
    WARNING: index 'main2': prealloc: failed to open /var/piler/sphinx/main2.sph: No such file or directory; NOT SERVING
    precaching index 'main3'
    WARNING: index 'main3': prealloc: failed to open /var/piler/sphinx/main3.sph: No such file or directory; NOT SERVING
    precaching index 'main4'
    WARNING: index 'main4': prealloc: failed to open /var/piler/sphinx/main4.sph: No such file or directory; NOT SERVING
    precaching index 'dailydelta1'
    WARNING: index 'dailydelta1': prealloc: failed to open /var/piler/sphinx/dailydelta1.sph: No such file or directory; NOT SERVING
    precaching index 'delta1'
    WARNING: index 'delta1': prealloc: failed to open /var/piler/sphinx/delta1.sph: No such file or directory; NOT SERVING
    precaching index 'tag1'
    WARNING: index 'tag1': prealloc: failed to open /var/piler/sphinx/tag1.sph: No such file or directory; NOT SERVING
    precaching index 'note1'
    WARNING: index 'note1': prealloc: failed to open /var/piler/sphinx/note1.sph: No such file or directory; NOT SERVING
    FATAL: no valid indexes to serve
    shutdown complete

  3. Dale Storrie reporter

    Hi thank you for the reply and the support.

    My sphinx.config base config is:

    source base{type = mysqlsql_host = localhostsql_db = pilersql_user = pilersql_pass = REMOVED
    
    sql_attr_uint = sizesql_attr_uint = sentsql_attr_uint = attachments}
    
    source delta : base{sql_query_pre = SET NAMES utf8mb4sql_query_pre  = REPLACE INTO sph_counter SELECT 1, IFNULL(MAX(id), 0) FROM sph_indexsql_query_post_index  = DELETE FROM sph_index WHERE id<=(SELECT max_doc_id FROM sph_counter WHERE counter_id=1)sql_query = SELECT <?php print SELECT_FIELDS; ?> FROM sph_index WHERE id <= (SELECT max_doc_id FROM sph_counter WHERE counter_id=1)
    

    I have the sock file as required:

    root:~/mailpiler/piler/piler-1.3.9 # ls /var/run/mysqld/
    mysqld.pid  mysqld.sock
    

    MySQL is listening on the correct port:

    root:~/mailpiler/piler/piler-1.3.9 [!2] # netstat -tlnp | grep mysql
    tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN      16793/mysqld
    

    I can login from localhost as the user:

    root:~/mailpiler/piler/piler-1.3.9 # mysql -u piler -p
    Enter password:
    Welcome to the MariaDB monitor.  Commands end with ; or \g.
    Your MariaDB connection id is 33
    Server version: 10.1.44-MariaDB-0ubuntu0.18.04.1 Ubuntu 18.04
    
    Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
    
    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    
    MariaDB [(none)]> show databases;
    +--------------------+
    | Database           |
    +--------------------+
    | information_schema |
    | piler              |
    +--------------------+
    2 rows in set (0.00 sec)
    
    MariaDB [(none)]>
    

    I have reformatted my server and reset up all up again and I still get the same outcome when I get to “make postinstall”

    Again thank you for the support.

  4. Dale Storrie reporter

    Ahh I found my issue, I had no mysql.sock inside of /tmp as I had incorrectly linked the file there as mysqld.sock and not mysql.sock.

    Thank for for the guidance and support.

  5. Log in to comment