Skip to content

GAMMU-MySQL Linking

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.

Gammu-MySQL Issues

Cmake:

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.

MySQL:

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:

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[75])

UPDATE!

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[75])” 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 -v

Gammu-smsd version 1.37.4
Compiled in features:
OS support:
– SHM
– DAEMON
– PID
– ALARM
– GETOPT
– GETOPT_LONG
– SYSLOG
Backend services:
– NULL
– FILES
– POSTGRESQL
– DBI
– ODBC

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.

$updatedb

$locate mariadb.repo

/etc/yum.repos.d/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

Conclusion

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:

  1. https://wammu.eu/docs/manual/smsd/config.html#mysql-service
  2. https://wammu.eu/docs/manual/smsd/mysql.html
  3. https://wammu.eu/docs/manual/gammu/
  4. https://wammu.eu/docs/manual/smsd/config.html#files-backend-options
  5. https://wammu.eu/docs/manual/config/index.html#gammurc
  6. https://wammu.eu/docs/manual/smsd/inject.html
  7. https://wammu.eu/docs/manual/smsd/monitor.html
  8. https://wammu.eu/download/gammu/
  9. http://manual.freeshell.org/gammu/gammu.html
  10. http://www.tecmint.com/install-lamp-in-centos-7/
  11. https://dev.mysql.com/doc/refman/5.7/en/alter-user.html
  12. https://mediatemple.net/community/products/dv/204404494/how-do-i-grant-privileges-in-mysql
  13. http://ask.xmodulo.com/fix-slow-ssh-login-issue-linux.html
  14. http://idroot.net/tutorials/completely-removing-mysql-server-centos/
  15. http://stackoverflow.com/questions/4489548/why-there-can-be-only-one-timestamp-column-with-current-timestamp-in-default-cla
  16. http://sharadchhetri.com/2013/12/26/install-mysql-server-5-6-in-centos-6-x-and-red-hat-6-x-linux/

 

 

Comments are closed.