Couldn't execute statment: SQL logic error or missing databa


Below is my environment:

OS: Cent OS 7.0 (64-Bit)
Asterisk version: 11.x
Database: My SQL

My SIP users are in the database. I am connected to data base from Asterisk through ODBC. Everything is working fine. But, I am getting the below message on Asterisk CLI:

db.c:332 ast_db_put: Couldn’t execute statment: SQL logic error or missing database

I checked in /etc/asterisk/asterisk.conf file and the folder of “astdbdir” is “/var/lib/asterisk” and the “/var/lib/asterisk” is existed. When I check this foler, “astdb.sqlite3” file is existed.

How to avoid in getting this message? I tried in internet. But, I didn’t get any possible solution. Can any body tell me the solution to solve this issue?

Thanks in advance.

Check which user is running the Asterisk-process.
Check wheter this user has read/write permissions to /var/lib/asterisk/astdb.sqlite3

The issue You’re facing is independent from MySQL or ODBC as it is related to Asterisk’s internal sqlite3-based database.


Thank you for your reply.

Asterisk is running with “astuser” and I have done the below steps:

adduser astuser --password ‘password’

chown astuser. /var/run/asterisk

chown -R astuser. /etc/asterisk

chown -R astuser. /var/{lib,log,spool}/asterisk

chown -R astuser. /usr/lib64/asterisk

Is there anything else that I need to do? Or Do I need to modify anything in the above steps?

Please suggest.

Thanks in advance.

I’ve not used Asterisk non-root, but I would question the wisdom of:

  • Setting a password on any daemon account. I would have thought it should have been no login allowed;
  • Setting anything under /usr/lib to be owned by anyone except root or bin.

Normally I would have said that anything under /etc/ should be owned by a core system account, but there are cases where Asterisk can legitimately update files there.

Hello David,

Thanks for your reply. If this is wrong, can you tell me the possible solution? Do you have suggestion to avoid “Re: Couldn’t execute statment: SQL logic error or missing database” message?


Hello abw1oim,

Any update would be appreciated.

Thank you.

If astuser has read/write-permissions to the astdb.sqlite3-file, the error is odd. To be honest: I’ve no idea, what else may cause the error except the file is corrupt for any reason.

If You don’t have any important data within the the asterisk-internal db You may try to stop asterisk, delete the file and start asterisk again. In this case the database file should be re-created automatically. Afterwards You may check, wheter the error disappears or not.

If You got any data within the db-file, just make a copy of the file before proceeding. Somewhere in the Net there should be a utility which allows to dump out the data of a sqlite-database …