Answer the question
In order to leave comments, you need to log in
How to fix "No database selected" error in Sphinx and Yii2?
There is a sphinx.conf config:
source base_source
{
type = mysql
sql_host = 127.0.0.1
sql_user = asdasd
sql_pass = asd
sql_db = db_bayboow
sql_port = 3306 # optional, default is 3306
}
.
.
.
searchd {
listen = 9312
listen = 9306:mysql41
log = /var/log/sphinxsearch/searchd.log
query_log = /var/log/sphinxsearch/query.log
pid_file = /var/log/sphinxsearch/searchd.pid
read_timeout = 5
max_children = 30
max_matches = 1000
seamless_rotate = 1
preopen_indexes = 0
unlink_old = 1
}
'sphinx' => [
'class' => 'yii\sphinx\Connection',
'dsn' => 'mysql:host=127.0.0.1;port=9306;',
'username' => asdasd,
'password' => asd,
],
Exception (Database Exception) "yii\db\Exception" with message "SQLSTATE[3D000]: Invalid catalog name: 1046 No database selected
The SQL being executed was: SELECT `id`, `name`, `link` FROM `products`"
mysql -h 127.0.0.1 --port=9306 -u asdasd -p asd
Answer the question
In order to leave comments, you need to log in
In the config, specify the database in the dns parameter, i.e. instead of "mysql:host=127.0.0.1;port=9306" write "mysql:host=127.0.0.1;dbname=db_bayboow;port=9306".
In general, I had the same error, only everything was indicated there as it should
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question