This post attempts to clarify/unify the procedure on Gammu-MySQL linking. In all honesty, this post should not exist. However, due to the incompatibilities or should I say finicky nature of Gammu as it relates to MySQL, I am left with no choice but to write a guide.
As I write this post, Gammu is at version 1.38.1, MySQL at 5.7, and CentOS at version 7. The first issue emanates from the latest stable release of Gammu requires CMake3. If you are coming from a default frugal installation of CentOS7, the problem will immediately arise during compile time. Although, the steps necessary to update cmake is provided also in this blog (CMake3: How to Compile from Source), the fact that it is a major hindrance to enjoying the benefits of Gammu cannot be ignored.
Gammu specifically requires the following storage mechanisms: MySQL as Files service, MySQL service, DBI service using SQLite, and ODBC. For CentOS 6 implementations, this would pose no problem. However, the world has since moved from CentOS 6 to 7. And in the recent stable release, MySQL is no longer provided as the default database. It is now MariaDB. Gammu has yet to provide support for this.
Another issue that needs to be addressed is the error laden SQL query provided by the Gammu documentation. The sql can accessed in the following locations:
- Gammu webiste — https://wammu.eu/docs/manual/smsd/mysql.html
- CentOS — /home/sam/gammu-1.38.1/docs/sql/mysql.sql; and
The aforementioned queries, if used as-is, the following errors pop-up: (1) utf8mb4 unknown; and (2) timestamp default incorrect table definition.
In the first instance, utf8mb4 can be easily resolved by replacing it with utf8. On the second, it can only be corrected by updating MySQL 5.1.3 (default) to MySQL 5.7 up. Apparently there are new functions and restrictions in the latest server implementation which are not recognized in the former.
To make a long story short, the easiest path to take is to uncheck MySQL during CentOS installation and compile/install it as described in this article MySQL 5.7 on Centos 7.
If you are coming from a CentOS6.5 installation, the parameters and problems are totally different.
DBI did not find any drivers, try using DriversPath option
Initialisation failed, stopping Gammu smsd: Failed to initialize DB driver. (DB_DRIVER)
Here’s another issue that ought not happen but does in the real world. After a successful install of Gammu and the configuration on the /root/.gammurc (general configuration) and /etc/gammu-smsdrc files (smsd specific configuration), you get the “DBI did not find any drivers, try using DriversPath option Initialisation failed, stopping Gammu smsd: Failed to initialize DB driver. (DB_DRIVER)” error.
After much head scratching, I found out that it is because mysql-devel has not been included into gammu while compiling the source code. Here’s how to test it:
Gammu-smsd version 1.37.4
Compiled in features:
As you can see, MySQL is not included in the backend services. To fix this, you need to uninstall gammu and start from scratch. But before you do, you must disable the mariadb.repo. To do this one must simply search for mariadb.repo then append enabled = 0 to it. The reason for this is that CentOS7 ships with mariadb as its main database. As discussed in this post, gammu only works with MySQL. Despite installing MySQL community server and clients, CentOS 7 still considers mariadb-devel as the default development environment thus, it will force this library on yum install mysql-devel. Should you say yes to this, it will unapologetically bombard you with errors because mariadb-devel conflicts with mysql-community-devel. The solution here is to disable the mariadb.repo.
$echo “enabled = 0” >>i /etc/yum.repos.d/mariadb.repo
$yum clean all
$yum install mysql-devel
Database creation errors using the gammu supplied .sql file
To be fair, gammu provides a database creation script in its documentation. To be blunschema.sqlt and totally unfair, it does not work. When run, it gives off too much query errors. I will no longer bombard you with the details. Instead, I will provide you with the .sql file that works for MySQL Distrib 5.6.35 and Gammu 1.37.x.x.
Download at your own risk: schema.sql
GAMMU SMSD Daemon Config file
This file resides in /etc/gammu-smsdrc. It must be created by hand.[smsd]
- Service = sql
- Driver = native_mysql
- PIN = 1234
- LogFile = /home/smsd.log
- User = smsd
- Password = smsd
- Host = localhost
- Database = smsd
To have a more-or-less painless experience in the installation of gammu especially if you intend to use MySQL as a storage facility, USE THE LATEST STABLE RELEASES OF CENTOS, GAMMU, CMAKE, and MYSQL.
For future reference: