SphinxQL + sphinxsearch table doesn't exists - mysql

Today I was trying to use sphinxsearch with SphinxQL but something going bad =\
First I installed sphinxsearch then I configured it, after that I created index forum_index using indexer --all. All finished without errors.
Then I included SphinxQl to my project, typed host and port which is listening sphinx and tried to make a query like in ReadMe of SphinxQL:
// create a SphinxQL Connection object to use with SphinxQL
$conn = new Connection();
$conn->setParams(array('host' => 'localhost', 'port' => 9306))
;
But it caused a database access error:
access denied www-data#localhost password NO
After that I set parameters of username and password in SphinxQL using
mysqli::real_connect()
Previous errors disappeared
Then I tried to make a test query:
$query = SphinxQL::create($conn)->select('column_one', 'colume_two')
->from('forum_index');
$result = $query->execute();
But I get an error:
table forum_index doesn't exists
I have a feel that my SphinxQL doesn't see sphinx or sphinx config and tries to make a simple query.
Have you any idea what's going wrong?

Please go to command line use the following command
mysql -P9306 --protocol=tcp --prompt='sphinxQL> '
Once get sphinxQL prompt enter the following command
sphinxQL> show tables;
If you set up everything correctly you can see the forum_index table in the list. Else check your searchd configuration section in your sphinx.conf file for proper configuration. My configuration look like this
searchd {
listen = 9315
listen = 9306:mysql41
log = /Users/XXXX/projects/sphinx/data/searchd.log
query_log = /Users/XXXX/projects/sphinx/data/query.log
read_timeout = 5
max_children = 30
pid_file = /Users/XXXX/projects/sphinx/data/searchd.pid
max_matches = 1000
seamless_rotate = 1
preopen_indexes = 0
unlink_old = 1
workers = threads
thread_stack = 1024K
}

I solved my problem by setting host = '127.0.0.1' in SphinxQL params

Related

DBInterface.connect returns MySQL.Connection(disconnected)

I'm trying to connect to a MySQL database. In the Documentation its recommended to use DBInterface.connect with a Type MySQL.Connection Object. The Database im trying to connect to gets listed with the mysql> SHOW DATABASES; command so there should be no problem on the MySQL side of things.
For now I implemented:
module Database
using MySQL
using DBInterface
const HOST = "localhost"
const USER = "root"
const PASS = "#####"
const DB = "databank"
const CONN = DBInterface.connect(MySQL.Connection, HOST, USER, PASS, db=DB)
export CONN
disconnect() = DBInterface.close!(CONN)
# gets called for cleanup
atexit(disconnect)
end
But when I call CONN from the REPL I get:
julia> using Database
julia> CONN
MySQL.Connection(disconnected)
julia>
I already checked this Question for answeres, but my implementation should be the same.
Later down the line I was hoping to use DBInterface.execute(CONN, sql) but I get the error ERROR: mysql connection has been closed or disconnected

julia mysql.jl use non default port

I'm trying to connect to a MySQL database using the mySQl.jl package. it seems to work fine when I'm using the standard mySQL port 3306, but I don't see where to specify a database on a different port. How is that accomplished?
From the help doc of mysql_connect (get it with ?mysql_connect at the REPL):
mysql_connect(host::String, user::String, passwd::String,
db::String = ""; port::Int64 = MYSQL_DEFAULT_PORT,
socket::String = MYSQL_DEFAULT_SOCKET, opts = Dict())
Connect to a MySQL database.
So just add a named parameter port= after the database name parameter. For example:
mysql_connect("localhost", "john", "password", "my_db", port=1234)

Asterisk 1.8 cdr-adaptive mysql

i'm having a little problem. I'm using Debian and I got asterisk 1.8 and I want to use CDR along with mysql.
In Asterisk 1.8 you apparently gotta use cdr-adaptive module instead of the regular. That is just what I did. Now I have 1 error when I "module reload cdr_adaptive_odbc.so" and I can't solve it :
WARNING[23172]: cdr_adaptive_odbc.c:123 load_config: No such connection 'MySQL-asterisk' in the 'adaptive-connection' section of cdr_adaptive_odbc.conf. Check res_odbc.conf.
Now here are all the files related, I can't understand what is wrong :
/etc/odbc.ini :
[MySQL]
Description = MySQL ODBC MyODBC Driver
Driver = /usr/lib/libmyodbc3.so
FileUsage = 1
[Text]
Description = ODBC for Text Files
Driver = /usr/lib/libodbctxt.so
Setup = /usr/lib/libodbctxtS.so
FileUsage = 1
CPTimeout =
CPReuse =
[PostgreSQL]
Description = PostgreSQL driver for Linux & Win32
Driver = /usr/lib/libodbcpsql.so
Setup = /usr/lib/libodbcpsqlS.so
FileUsage = 1
[DB2]
Description = DB2 Driver
Driver = /opt/IBM/db2/V8.1/lib64/libdb2.so
FileUsage = 1
DontDLClose = 1
DMEnvAttr = SQL_ATTR_UNIXODBC_ENVATTR={DB2INSTANCE=db2inst1}
[MySQL-asterisk]
Description = MySQL asterisk database
Driver = MySQL
Socket = /var/run/mysqld/mysqld.sock
Server = localhost
User = root
Password = XXXXX
Database = ics
Option = 3
/etc/asterisk/cdr_adaptive_odbc.conf :
[adaptive-connection]
connection = MySQL-asterisk
table = cdr
alias start => calldate
/etc/asterisk/res_odbc.conf :
[Asterisk]
enabled => yes
dsn => MySQL-asterisk
username => root
password => XXX
;pooling => no
;limit => 0
pre-connect => yes
This is what I get when i check the cdd status :
Call Detail Record (CDR) settings
----------------------------------
Logging: Enabled
Mode: Simple
Log unanswered calls: No
* Registered Backends
-------------------
Adaptive ODBC
cdr-custom
ODBC
csv
radius
res_config_sqlite
And this is what I get when i check de odcb
ODBC DSN Settings
-----------------
Name: Asterisk
DSN: MySQL-asterisk
I can't figure out what's wrong. Anyone has an idea ?
I assume you've fixed this now. I ran into a similar issue and the problem stemmed from the documentation. It refers to connection= in cdr_adaptive_odbc.conf being the DSN name. It's the name you want and not the DSN. So in your case:
connection = Asterisk
then at the command line do a
CLI> module reload cdr_adaptive_odbc.so
and you should see a screenfull as Asterisk finds the tables and does any mappings you have specified.

Mysql Error = Can't create UNIX socket (24)

I have got the following exception
Mysql Caught Exception = Can't create UNIX socket (24).
I know that UNIX system error 24. That's "too many open files."
I refered this question ,:OperationalError: (2001, "Can't create UNIX socket (24)")
But I need to understand the exact problem.
In my code I execute multiple select query and store the result,not using free_result method in between.
Can it be the case of this error : Can't create UNIX socket (24)
Here is my code :
pthread_mutex_lock(&mysqlMutex);
mysql = mysql_init(NULL);
my_bool reconnect = 1;
MYSQL* connection;
mysql_options(mysql, MYSQL_OPT_RECONNECT, &reconnect);
connection = mysql_real_connect( server,user,password, database_name, 0, NULL, 0 );
if(connection == NULL)
{
//Connection failed.Exception Handling
}
//Execute query :SELECT * from user ;
mysql_query(mysql, getuser_query);
MYSQL_RES *mysql_res = mysql_store_result(mysql);
// Query # 2
// SELECT * from usergroup.
mysql_query(m_pMysql, userGroup_query);
mysql_res = mysql_store_result(mysql);
// Query # 3
// Query # 4
At the last:
//free mysql memory
mysql_free_result(mysql_res);
mysql_close(mysql);
pthread_mutex_unlock(&mysqlMutex);
You are perhaps opening too many simultaneous connections to mysql server. You need to increase available FDs to mysql process. You can usually do so with /etc/security/limits* in your linux distro.
You can also look at this question: Mysql decrease opened files

PHP5-FPM and MYSQL

I'm using lighttpd and pfp-fpm.
All work correctly, but if I call a mysql_connect() on my php scripts I get an empty page.
Like a "denied operation".
This is my php-fpm.conf pool
[example.com]
listen = 127.0.0.1:9001
listen.backlog = -1
user = example.com
group = example.com
pm = dynamic
pm.max_requests = 0
pm.max_children = 2
pm.start_servers = 1
pm.min_spare_servers = 1
pm.max_spare_servers = 1
chroot = /home/vhosts/example.com/
request_terminate_timeout = 2
request_slowlog_timeout = 1
slowlog = /home/vhosts/example.com/log/php-slow.log
catch_workers_output = yes
env[HOSTNAME] = $HOSTNAME
env[PATH] = /usr/local/bin:/usr/bin:/bin
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp
This is my lighttpd vhost:
$HTTP["host"] =~ "(^|.)example\.com$" {
server.document-root = "/home/vhosts/example.com/web"
server.errorlog = "/home/vhosts/example.com/log/error.log"
accesslog.filename = "/home/vhosts/example.com/log/access.log"
fastcgi.server = (
".php" => (
"localhost" => (
"docroot" => "/web",
"host" => "127.0.0.1",
"port" => "9001"
)
)
)
}
What is wrong? If I don't use mysql I can see the result of the php script correctly.
Turning on error display and posting those errors would be helpful, but since you can use mysql without chrooting php, I guess you are getting some connection error, since php tries to connect to mysql on localhost using socket ( php compiled with --with-mysql-sock=/var/mysql.sock), and most likely this socket is outside your chrooted environment.
You can try:
Recompiling php to not use socket
creating hard link to socket in your chrooted path
using some internal ip (like 10.0.0.1,192.168.0.1) instead of loopback
Seems to me all the problems are because of the user and group being example.com
i guess that user doesnt have rights to perform the requested tasks