我是Asterisk的新手,这是我第一次尝试连接数据库(MySQL).但我一直收到此错误[unixODBC] [驱动程序管理器]未找到数据源名称,并且未指定默认驱动程序.这是我的设置:
/etc/odbcinst.int
[Default]
Driver = /usr/lib/x86_64-linux-gnu/odbc/libmyodbc.so
[MySQL]
Description = ODBC for MySQL
Driver = /usr/lib/x86_64-linux-gnu/odbc/libmyodbc.so
Setup = /usr/lib/x86_64-linux-gnu/odbc/libodbcmyS.so
FileUsage = 1
;UsageCount = 2
/etc/odbc.ini
[MYSQL-DNS]
Driver =MySQL
Description = MySQL connection to ‘My Voice’ database
Trace = Yes
TraceFile = /tmp/odbc.log
Server =localhost
Port =3306
Database =my_database
UserName =myuser
Password =mypass
Option = 3
Socket =/var/run/mysqld/mysqld.sock
/var/lib/asterisk/.profile
export ODBCINI=/etc/odbc.ini
export ODBCSYSINI=/etc
我还将odbcinst.ini和odbc.ini分别复制到〜/ .odbcinst.ini和〜/ .odbc.ini,并复制到/ var / lib / asterisk /只是为了清除所有疑问.
res_odbc.conf
[ENV]
[my_database]
enabled => yes
dsn =>MYSQL-DNS
username => myuser
password => mypass
pre-connect => yes
sanitysql => select 1
;idlecheck => 3600
share_connections => yes
pooling => no
limit => 1
;isolation=repeatable_read
命令odbcinst -j输出
$odbcinst -j
unixODBC 2.3.2
DRIVERS............: /etc/odbcinst.ini
SYSTEM DATA SOURCES: /etc/odbc.ini
FILE DATA SOURCES..: /etc/ODBCDataSources
USER DATA SOURCES..: /etc/odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8
我想我有时会在/usr/lib之前做一个符号链接,从而找到libmyodbc.so输出
$locate libmyodbc.so
/usr/lib/libmyodbc.so
/usr/lib/x86_64-linux-gnu/odbc/libmyodbc.so
我还添加了x权限ie(从644更改为755):
ls -alsh /usr/lib/x86_64-linux-gnu/odbc/
显示755 * .so
日志输出
res_odbc.c: Connecting my_database
[Aug 1 09:32:40] WARNING[27846] res_odbc.c: res_odbc: Error SQLConnect=-1 errno=0 [unixODBC][Driver Manager]Data source name not found, and no default driver specified
[Aug 1 09:32:40] WARNING[27846] res_odbc.c: Failed to connect to my_database
[Aug 1 09:32:40] ERROR[27846] res_config_odbc.c: No database handle available with the name of 'my_database' (check res_odbc.conf)
解决方法:
您可以将连接检查为
isql -vvv MYSQL-DNS
这将清楚地说明你出了什么问题.