An error occurred when opensips started the service“ ERROR:core :db_ check_ table_ Version: invalid version 7 for Table dialog found “

recently engaged in SIP phone related projects, encountered a lot of trouble when building opensips server, most of which could be solved by looking up information, but today I encountered a problem that I could not find the solution on the Internet, so I decided to share it with you.
virtual system is Ubuntu14.04
opensips version is 2.1.2
when opensips service is started, the following error occurs:

root@sjt-VirtualBox:/usr/local/opensips_proxy/sbin# ./opensipsctl start

INFO: Starting OpenSIPS : 

ERROR: PID file /var/run/ does not exist -- OpenSIPS start failed

view the ERROR log and prompt “ERROR:core:db_check_table_version: invalid version 7 for table dialog found”, assuming there was a problem with the database creation

root@sjt-VirtualBox:/usr/local/opensips_proxy/sbin# tail -f /var/log/syslog
Oct 13 08:40:29 sjt-VirtualBox ./opensips[2851]: INFO:alias_db:mod_init: initializing...
Oct 13 08:40:29 sjt-VirtualBox ./opensips[2851]: INFO:dialog:mod_init: Dialog module - initializing
Oct 13 08:40:29 sjt-VirtualBox ./opensips[2851]: INFO:core:evi_publish_event: Registered event <E_DLG_STATE_CHANGED(12)>
Oct 13 08:40:29 sjt-VirtualBox ./opensips[2851]: ERROR:core:db_check_table_version: invalid version 7 for table dialog found, expected 10
Oct 13 08:40:29 sjt-VirtualBox ./opensips[2851]: ERROR:dialog:init_dlg_db: error during table version check.
Oct 13 08:40:29 sjt-VirtualBox ./opensips[2851]: ERROR:dialog:mod_init: failed to initialize the DB support
Oct 13 08:40:29 sjt-VirtualBox ./opensips[2851]: ERROR:core:init_mod: failed to initialize module dialog
Oct 13 08:40:29 sjt-VirtualBox ./opensips[2851]: ERROR:core:main: error while initializing modules

creates opensips database


root@sjt-VirtualBox:/usr/local/opensips_proxy/sbin# ./opensipsdbctl create
MySQL password for root: 
INFO: test server charset
INFO: creating database opensips ...
ERROR 1007 (HY000) at line 1: Can't create database 'opensips'; database exists
ERROR: Creating database opensips failed!

indicates that the database already exists and the creation failed. The reason was finally found, because I had built a database before, and this installation configuration of OpenSiPs did not match the previous database, so the OpenSips service could not be started.
therefore, delete the previous database, recreate, execute./opensipsdbctl reinit.

root@sjt-VirtualBox:/usr/local/opensips_proxy/sbin# ./opensipsdbctl reinit
MySQL password for root: 
INFO: Database opensips deleted
INFO: test server charset
INFO: creating database opensips ...
INFO: Using table engine MyISAM.
INFO: Core OpenSIPS tables successfully created.
Install presence related tables? (y/n): y
INFO: creating presence tables into opensips ...
INFO: Presence tables successfully created.
Install tables for imc cpl siptrace domainpolicy carrierroute userblacklist b2b cachedb_sql registrant call_center fraud_detection? (y/n): y
INFO: creating extra tables into opensips ...
INFO: Extra tables successfully created.

open opensips service again, success!

root@sjt-VirtualBox:/usr/local/opensips_proxy/sbin# ./opensipsctl start

INFO: Starting OpenSIPS : 
INFO: started (pid: 3128)

Read More: