Answer the question
In order to leave comments, you need to log in
Yii2 sphinx what is wrong?
Actually, I turned on sphinx on the hosting, installed the extension in yii2, everything seems to be set up, but when I search, I get an error
SQLSTATE[3D000]: Invalid catalog name: 1046 No database selected
The SQL being executed was: SHOW TABLES
what did I do wrong?
here are all the settings.
this is in web.php
'sphinx' => [
'class' => 'yii\sphinx\Connection',
'dsn' => 'mysql:host=localhost;port=9306;',
'username' => '*****',
'password' => '*****',
],
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=localhost;port=9306;dbname=theodo_rentin',
'username' => '*******',
'password' => '********',
'charset' => 'utf8',
source rentin
{
type = mysql
sql_host = localhost
sql_user = ******
sql_pass = ******
sql_db = theodo_rentin
sql_port = 9306
sql_query_pre = SET NAMES utf8
sql_query = SELECT id, title, description FROM post
sql_attr_uint = id
sql_field_string = title
sql_field_string = description
}
index idx_post
{
source = rentin
path = /var/lib/sphinx/data/idx_post
morphology = stem_enru
min_word_len = 2
index_exact_words = 1
expand_keywords = 1
html_strip = 1
min_infix_len = 2
}
indexer
{
mem_limit = 240M
}
searchd
{
log = /var/log/sphinx/searchd.log
query_log = /var/log/sphinx/query.log
pid_file = /var/run/sphinx/searchd.pid
listen = 9312
listen = 9306:mysql41
}
Answer the question
In order to leave comments, you need to log in
The problem lies in this line:
It's not very obvious, but with the default settings, if host is specified as localhost, then the mysql driver ignores TCP and accesses the socket directly.
Therefore, the sphinx section in the settings creates a connection to the mysql server instead of sphinx.
To solve the problem, you must either specify 127.0.0.1 instead of localhost or add a parameter that hard specifies to use the tcp protocol
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question