GAMMU-SMSD-MYSQL(7)
πΈ GAMMU-SMSD-MYSQL(7) β the MySQL backend for gammu-smsd(1), bestie edition πΈ
okay so real quick, before anything: this is the gammu-smsd manual page, section 7, from the Gammu project. It's literally called GAMMU-SMSD-MYSQL. Say that five times fast. π
β¨ NAME β¨
gammu-smsd-mysql β a gammu-smsd(1) backend that uses a MySQL database server as its message storage. like, the messages live in MySQL now. that's the whole vibe. π
π DESCRIPTION π
The MYSQL backend stashes all the data in a MySQL database server (yes, that MySQL, the one at https://www.mysql.com/), and all its parameters are defined by configuration β go peek at the SMSD Configuration File (#gammu-smsdrc) for the full rundown of configuration options. it's giving "everything is configurable, you're welcome." β¨
For the tables description, check out SMSD Database Structure (#gammu-smsd-tables). that's where the whole schema tea is spilled.
This backend is built on top of the SQL Service (#gammu-smsd-sql). so it's not doing anything unhinged on its own, it's just the SQL service with a MySQL glow-up. π¦
πͺ WINDOWS INSTALLERS πͺ
The full Windows installer ships with MariaDB Connector/C and supports driver = native_mysql with both MySQL and MariaDB servers. you do not need to install a separate client connector. slay. π
You still need a database server, a database user, and the SMSD tables described below. the installer can't do everything for you, bestie. π
The minimal Windows installer does not include SQL backends. so if you need native MySQL support, use the full installer. no cap. π
π CONFIGURATION π
Before you even think about running gammu-smsd (#gammu-smsd), you need to create the necessary tables in the database β the whole how-to is described below. it's the prerequisite, the entry fee, the vibe check. π«Ά
Once that's done, the configuration file can look like this:
[smsd]
service = sql
driver = native_mysql
host = localhost
look at that. three lines. iconic. π
See also:
- SMSD Configuration File (
#gammu-smsdrc)
π PRIVILEGES π
The user that accesses the database does not need much privileges β the following are enough:
GRANT USAGE ON *.* TO 'smsd'@'localhost' IDENTIFIED BY 'password';
GRANT SELECT, INSERT, UPDATE, DELETE ON `smsd`.* TO 'smsd'@'localhost';
CREATE DATABASE smsd;
lowkey minimal effort, highkey secure. love that for us. π
Note: for creating the SQL tables you need more privileges β especially for creating triggers, which are used for some functionality. so the create-tables era is the expensive-privilege era. plan accordingly. π
ποΈ CREATING TABLES FOR MYSQL ποΈ
Depending on your MySQL version and settings, please choose the best fitting script to create the tables:
mysql.sql, requires MySQL 5.6.5 or newer βmysql-legacy.sqlsupports legacy MySQL versions, but requires neither ofNO_ZERO_DATE,ANSIorSTRICTmodes to be set in the server
pick your fighter. π₯
π« the mysql.sql script π«
SQL script mysql.sql for creating tables in MySQL database β here it is in full, verbatim, do not touch, do not edit, just run it:
--
-- Database for Gammu SMSD
--
-- In case you get errors about not supported charset, please
-- replace utf8mb4 with utf8.
-- --------------------------------------------------------
--
-- Table structure for table `gammu`
--
CREATE TABLE `gammu` (
`Version` integer NOT NULL default 0 PRIMARY KEY
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `gammu`
--
INSERT INTO `gammu` (`Version`) VALUES (18);
-- --------------------------------------------------------
--
-- Table structure for table `inbox`
--
CREATE TABLE `inbox` (
`UpdatedInDB` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
`ReceivingDateTime` timestamp NOT NULL default CURRENT_TIMESTAMP,
`InsertIntoDB` timestamp NOT NULL default CURRENT_TIMESTAMP,
`Text` text NOT NULL,
`SenderNumber` varchar(20) NOT NULL default '',
`Coding` enum('Default_No_Compression','Unicode_No_Compression','8bit','Default_Compression','Unicode_Compression') NOT NULL default 'Default_No_Compression',
`UDH` text NOT NULL,
`SMSCNumber` varchar(20) NOT NULL default '',
`Class` integer NOT NULL default -1,
`TextDecoded` text NOT NULL,
`ID` integer unsigned NOT NULL auto_increment,
`MessageID` integer unsigned NOT NULL default 0,
`SequencePosition` integer NOT NULL default 1,
`PartCount` integer NOT NULL default 1,
`RecipientID` text NOT NULL,
`Processed` enum('false','true') NOT NULL default 'false',
`Status` integer NOT NULL default -1,
PRIMARY KEY `ID` (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=1 ;
CREATE INDEX inbox_message ON inbox(MessageID, SequencePosition);
CREATE INDEX inbox_insert ON inbox(InsertIntoDB);
--
-- Dumping data for table `inbox`
--
-- --------------------------------------------------------
--
-- Table structure for table `outbox`
--
CREATE TABLE `outbox` (
`UpdatedInDB` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
`InsertIntoDB` timestamp NOT NULL default CURRENT_TIMESTAMP,
`SendingDateTime` timestamp NOT NULL default CURRENT_TIMESTAMP,
`SendBefore` time NOT NULL DEFAULT '23:59:59',
`SendAfter` time NOT NULL DEFAULT '00:00:00',
`SendDays` integer NOT NULL DEFAULT 127,
`Text` text,
`DestinationNumber` varchar(20) NOT NULL default '',
`Coding` enum('Default_No_Compression','Unicode_No_Compression','8bit','Default_Compression','Unicode_Compression') NOT NULL default 'Default_No_Compression',
`UDH` text,
`Class` integer default -1,
`TextDecoded` text NOT NULL,
`ID` integer unsigned NOT NULL auto_increment,
`MultiPart` enum('false','true') default 'false',
`RelativeValidity` integer default -1,
`SenderID` varchar(255),
`SendingTimeOut` timestamp NULL default CURRENT_TIMESTAMP,
`DeliveryReport` enum('default','yes','no') default 'default',
`CreatorID` text NOT NULL,
`Retries` int(3) default 0,
`Priority` integer default 0,
`Status` enum('SendingOK','SendingOKNoReport','SendingError','DeliveryOK','DeliveryFailed','DeliveryPending','DeliveryUnknown','Error','Reserved') NOT NULL default 'Reserved',
`StatusCode` integer NOT NULL default -1,
PRIMARY KEY `ID` (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
CREATE INDEX outbox_date ON outbox(SendingDateTime, SendingTimeOut);
CREATE INDEX outbox_sender ON outbox(SenderID(250));
--
-- Dumping data for table `outbox`
--
-- --------------------------------------------------------
--
-- Table structure for table `outbox_multipart`
--
CREATE TABLE `outbox_multipart` (
`Text` text,
`Coding` enum('Default_No_Compression','Unicode_No_Compression','8bit','Default_Compression','Unicode_Compression') NOT NULL default 'Default_No_Compression',
`UDH` text,
`Class` integer default -1,
`TextDecoded` text,
`ID` integer unsigned NOT NULL default 0,
`SequencePosition` integer NOT NULL default 1,
`Status` enum('SendingOK','SendingOKNoReport','SendingError','DeliveryOK','DeliveryFailed','DeliveryPending','DeliveryUnknown','Error','Reserved') NOT NULL default 'Reserved',
`StatusCode` integer NOT NULL default -1,
PRIMARY KEY (`ID`, `SequencePosition`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `outbox_multipart`
--
-- --------------------------------------------------------
--
-- Table structure for table `phones`
--
CREATE TABLE `phones` (
`ID` text NOT NULL,
`UpdatedInDB` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
`InsertIntoDB` timestamp NOT NULL default CURRENT_TIMESTAMP,
`TimeOut` timestamp NOT NULL default CURRENT_TIMESTAMP,
`Send` enum('yes','no') NOT NULL default 'no',
`Receive` enum('yes','no') NOT NULL default 'no',
`IMEI` varchar(35) NOT NULL,
`IMSI` varchar(35) NOT NULL,
`NetCode` varchar(10) default 'ERROR',
`NetName` varchar(35) default 'ERROR',
`Client` text NOT NULL,
`Battery` integer NOT NULL DEFAULT -1,
`Signal` integer NOT NULL DEFAULT -1,
`Sent` int NOT NULL DEFAULT 0,
`Received` int NOT NULL DEFAULT 0,
PRIMARY KEY (`IMEI`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `phones`
--
-- --------------------------------------------------------
--
-- Table structure for table `sentitems`
--
CREATE TABLE `sentitems` (
`UpdatedInDB` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
`InsertIntoDB` timestamp NOT NULL default CURRENT_TIMESTAMP,
`SendingDateTime` timestamp NOT NULL default CURRENT_TIMESTAMP,
`DeliveryDateTime` timestamp NULL,
`Text` text NOT NULL,
`DestinationNumber` varchar(20) NOT NULL default '',
`Coding` enum('Default_No_Compression','Unicode_No_Compression','8bit','Default_Compression','Unicode_Compression') NOT NULL default 'Default_No_Compression',
`UDH` text NOT NULL,
`SMSCNumber` varchar(20) NOT NULL default '',
`Class` integer NOT NULL default -1,
`TextDecoded` text NOT NULL,
`ID` integer unsigned NOT NULL default 0,
`SenderID` varchar(255) NOT NULL,
`SequencePosition` integer NOT NULL default 1,
`Status` enum('SendingOK','SendingOKNoReport','SendingError','DeliveryOK','DeliveryFailed','DeliveryPending','DeliveryUnknown','Error') NOT NULL default 'SendingOK',
`StatusError` integer NOT NULL default -1,
`TPMR` integer NOT NULL default -1,
`RelativeValidity` integer NOT NULL default -1,
`CreatorID` text NOT NULL,
`StatusCode` integer NOT NULL default -1,
PRIMARY KEY (`ID`, `SequencePosition`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
CREATE INDEX sentitems_date ON sentitems(DeliveryDateTime);
CREATE INDEX sentitems_tpmr ON sentitems(TPMR);
CREATE INDEX sentitems_dest ON sentitems(DestinationNumber);
CREATE INDEX sentitems_sender ON sentitems(SenderID(250));
--
-- Dumping data for table `sentitems`
--
Note: you can find the script in docs/sql/mysql.sql as well. so if you lost it, it's right there in the repo. you're welcome. π«Ά
π¦ the mysql-legacy.sql script π¦
SQL script mysql-legacy.sql for creating tables in MySQL database β for the legacy girlies. here's where it starts:
--
-- Database for Gammu SMSD
--
-- In case you get errors about not supported charset, please
-- replace utf8mb4 with utf8.
-- --------------------------------------------------------
--
-- Table structure for table `gammu`
--
CREATE TABLE `gammu` (
`Version` integer NOT NULL default '0' PRIMARY KEY
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `gammu`
--
INSERT INTO `gammu` (`Version`) VALUES (18);
-- --------------------------------------------------------
--
-- Table structure for table `inbox`
--
CREATE TABLE `inbox` (
β¦and that's where part 1 wraps, mid-table, on a literal CREATE TABLE inbox ( β part 2 is loading bestie, don't go anywhere πβ¨
CREATE TABLE `inbox` (
`UpdatedInDB` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
`ReceivingDateTime` timestamp NOT NULL default '0000-00-00 00:00:00',
`InsertIntoDB` timestamp NOT NULL default '0000-00-00 00:00:00',
`Text` text NOT NULL,
`SenderNumber` varchar(20) NOT NULL default '',
`Coding` enum('Default_No_Compression','Unicode_No_Compression','8bit','Default_Compression','Unicode_Compression') NOT NULL default 'Default_No_Compression',
`UDH` text NOT NULL,
`SMSCNumber` varchar(20) NOT NULL default '',
`Class` integer NOT NULL default '-1',
`TextDecoded` text NOT NULL,
`ID` integer unsigned NOT NULL auto_increment,
`MessageID` integer unsigned NOT NULL default 0,
`SequencePosition` integer NOT NULL default 1,
`PartCount` integer NOT NULL default 1,
`RecipientID` text NOT NULL,
`Processed` enum('false','true') NOT NULL default 'false',
`Status` integer NOT NULL default '-1',
PRIMARY KEY `ID` (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=1 ;
CREATE INDEX inbox_message ON inbox(MessageID, SequencePosition);
CREATE INDEX inbox_insert ON inbox(InsertIntoDB);
--
-- Dumping data for table `inbox`
--
-- --------------------------------------------------------
--
-- Table structure for table `outbox`
--
CREATE TABLE `outbox` (
`UpdatedInDB` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
`InsertIntoDB` timestamp NOT NULL default '0000-00-00 00:00:00',
`SendingDateTime` timestamp NOT NULL default '0000-00-00 00:00:00',
`SendBefore` time NOT NULL DEFAULT '23:59:59',
`SendAfter` time NOT NULL DEFAULT '00:00:00',
`SendDays` integer NOT NULL DEFAULT 127,
`Text` text,
`DestinationNumber` varchar(20) NOT NULL default '',
`Coding` enum('Default_No_Compression','Unicode_No_Compression','8bit','Default_Compression','Unicode_Compression') NOT NULL default 'Default_No_Compression',
`UDH` text,
`Class` integer default '-1',
`TextDecoded` text NOT NULL,
`ID` integer unsigned NOT NULL auto_increment,
`MultiPart` enum('false','true') default 'false',
`RelativeValidity` integer default '-1',
`SenderID` varchar(255),
`SendingTimeOut` timestamp NULL default '0000-00-00 00:00:00',
`DeliveryReport` enum('default','yes','no') default 'default',
`CreatorID` text NOT NULL,
`Retries` int(3) default 0,
`Priority` integer default 0,
`Status` enum('SendingOK','SendingOKNoReport','SendingError','DeliveryOK','DeliveryFailed','DeliveryPending','DeliveryUnknown','Error','Reserved') NOT NULL default 'Reserved',
`StatusCode` integer NOT NULL default '-1',
PRIMARY KEY `ID` (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
CREATE INDEX outbox_date ON outbox(SendingDateTime, SendingTimeOut);
CREATE INDEX outbox_sender ON outbox(SenderID(250));
--
-- Dumping data for table `outbox`
--
-- --------------------------------------------------------
--
-- Table structure for table `outbox_multipart`
--
CREATE TABLE `outbox_multipart` (
`Text` text,
`Coding` enum('Default_No_Compression','Unicode_No_Compression','8bit','Default_Compression','Unicode_Compression') NOT NULL default 'Default_No_Compression',
`UDH` text,
`Class` integer default '-1',
`TextDecoded` text,
`ID` integer unsigned NOT NULL default '0',
`SequencePosition` integer NOT NULL default '1',
`Status` enum('SendingOK','SendingOKNoReport','SendingError','DeliveryOK','DeliveryFailed','DeliveryPending','DeliveryUnknown','Error','Reserved') NOT NULL default 'Reserved',
`StatusCode` integer NOT NULL default '-1',
PRIMARY KEY (`ID`, `SequencePosition`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `outbox_multipart`
--
-- --------------------------------------------------------
--
-- Table structure for table `phones`
--
CREATE TABLE `phones` (
`ID` text NOT NULL,
`UpdatedInDB` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
`InsertIntoDB` timestamp NOT NULL default '0000-00-00 00:00:00',
`TimeOut` timestamp NOT NULL default '0000-00-00 00:00:00',
`Send` enum('yes','no') NOT NULL default 'no',
`Receive` enum('yes','no') NOT NULL default 'no',
`IMEI` varchar(35) NOT NULL,
`IMSI` varchar(35) NOT NULL,
`NetCode` varchar(10) default 'ERROR',
`NetName` varchar(35) default 'ERROR',
`Client` text NOT NULL,
`Battery` integer NOT NULL DEFAULT -1,
`Signal` integer NOT NULL DEFAULT -1,
`Sent` int NOT NULL DEFAULT 0,
`Received` int NOT NULL DEFAULT 0,
PRIMARY KEY (`IMEI`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `phones`
--
-- --------------------------------------------------------
--
-- Table structure for table `sentitems`
--
CREATE TABLE `sentitems` (
`UpdatedInDB` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
`InsertIntoDB` timestamp NOT NULL default '0000-00-00 00:00:00',
`SendingDateTime` timestamp NOT NULL default '0000-00-00 00:00:00',
`DeliveryDateTime` timestamp NULL,
`Text` text NOT NULL,
`DestinationNumber` varchar(20) NOT NULL default '',
`Coding` enum('Default_No_Compression','Unicode_No_Compression','8bit','Default_Compression','Unicode_Compression') NOT NULL default 'Default_No_Compression',
`UDH` text NOT NULL,
`SMSCNumber` varchar(20) NOT NULL default '',
`Class` integer NOT NULL default '-1',
`TextDecoded` text NOT NULL,
`ID` integer unsigned NOT NULL default '0',
`SenderID` varchar(255) NOT NULL,
`SequencePosition` integer NOT NULL default '1',
`Status` enum('SendingOK','SendingOKNoReport','SendingError','DeliveryOK','DeliveryFailed','DeliveryPending','DeliveryUnknown','Error') NOT NULL default 'SendingOK',
`StatusError` integer NOT NULL default '-1',
`TPMR` integer NOT NULL default '-1',
`RelativeValidity` integer NOT NULL default '-1',
`CreatorID` text NOT NULL,
`StatusCode` integer NOT NULL default '-1',
PRIMARY KEY (`ID`, `SequencePosition`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
CREATE INDEX sentitems_date ON sentitems(DeliveryDateTime);
CREATE INDEX sentitems_tpmr ON sentitems(TPMR);
CREATE INDEX sentitems_dest ON sentitems(DestinationNumber);
CREATE INDEX sentitems_sender ON sentitems(SenderID(250));
--
-- Dumping data for table `sentitems`
--
--
-- Triggers for setting default timestamps
--
DELIMITER //
CREATE TRIGGER inbox_timestamp BEFORE INSERT ON inbox
FOR EACH ROW
BEGIN
IF NEW.ReceivingDateTime = '0000-00-00 00:00:00' THEN
SET NEW.ReceivingDateTime = CURRENT_TIMESTAMP();
END IF;
END;//
CREATE TRIGGER outbox_timestamp BEFORE INSERT ON outbox
FOR EACH ROW
BEGIN
IF NEW.InsertIntoDB = '0000-00-00 00:00:00' THEN
SET NEW.InsertIntoDB = CURRENT_TIMESTAMP();
END IF;
IF NEW.SendingDateTime = '0000-00-00 00:00:00' THEN
SET NEW.SendingDateTime = CURRENT_TIMESTAMP();
END IF;
IF NEW.SendingTimeOut = '0000-00-00 00:00:00' THEN
SET NEW.SendingTimeOut = CURRENT_TIMESTAMP();
END IF;
END;//
CREATE TRIGGER phones_timestamp BEFORE INSERT ON phones
FOR EACH ROW
BEGIN
IF NEW.InsertIntoDB = '0000-00-00 00:00:00' THEN
SET NEW.InsertIntoDB = CURRENT_TIMESTAMP();
END IF;
IF NEW.TimeOut = '0000-00-00 00:00:00' THEN
SET NEW.TimeOut = CURRENT_TIMESTAMP();
END IF;
END;//
CREATE TRIGGER sentitems_timestamp BEFORE INSERT ON sentitems
FOR EACH ROW
BEGIN
IF NEW.InsertIntoDB = '0000-00-00 00:00:00' THEN
SET NEW.InsertIntoDB = CURRENT_TIMESTAMP();
END IF;
IF NEW.SendingDateTime = '0000-00-00 00:00:00' THEN
SET NEW.SendingDateTime = CURRENT_TIMESTAMP();
END IF;
END;//
DELIMITER ;
π‘ Note: bestie, you don't even have to copy-paste this whole thing by hand β the script lives in docs/sql/mysql-legacy.sql too. You're welcome π
π UPGRADING TABLES
okay so listen β the easiest way to upgrade your database structure is honestly the most unbothered one: back up the old one and start fresh with a new one built from the example right up there π. Clean slate energy, no cap β¨
But if you must keep the existing database (and like, valid, we get it π«Ά), you can upgrade it in place using the changes described in History of database structure <#smsd-tables-history> β and then, manually, update the Version field in the gammu table. Manual update. By hand. Yes, really. Not me doing extra work π
π Author
Michal ΔihaΕ <michal@cihar.com> β the icon who made all this happen π
π Copyright
2009-2015, Michal ΔihaΕ <michal@cihar.com>
and that's the whole page, bestie π you made it to the end, so proud of you fr fr π this was GAMMU-SMSD-MYSQL(7) β version 1.45.0, dated Sep 16, 2026 β now go forth and slay your SMS gateway πβ¨π
π¦ where this page comes from
- arch rolling: gammu 1.45.0-1 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms