summaryrefslogtreecommitdiff
path: root/docs/manual/smsd/mysql.rst
blob: c446ba4a513e5462d64036ffb7e20c7be4540cdb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
.. _gammu-smsd-mysql:

MySQL Backend
=============

Description
-----------

MYSQL backend stores all data in a `MySQL`_ database server, which parameters are
defined by configuration (see :ref:`gammu-smsdrc` for description of configuration
options).

For tables description see :ref:`gammu-smsd-tables`.

This backend is based on :ref:`gammu-smsd-sql`.

Configuration
-------------

Before running :ref:`gammu-smsd` you need to create necessary tables in the
database, which is described below.

The configuration file then can look like:

.. code-block:: ini

    [smsd]
    service = sql
    driver = native_mysql
    host = localhost

.. seealso:: :ref:`gammu-smsdrc`

Privileges
----------

The user accessing the database does not need much privileges, the following
privileges should be enough:

.. code-block:: sql

    GRANT USAGE ON *.* TO 'smsd'@'localhost' IDENTIFIED BY 'password';

    GRANT SELECT, INSERT, UPDATE, DELETE ON `smsd`.* TO 'smsd'@'localhost';

    CREATE DATABASE smsd;

.. note::

   For creating the SQL tables you need more privileges, especially for
   creating triggers, which are used for some functionality.

.. _MySQL: http://www.mysql.com/

.. _mysql-create:

Creating tables
---------------

SQL script for creating tables in MySQL database:

.. literalinclude:: ../../sql/mysql.sql
   :language: mysql

.. note::

    You can find the script in :file:`docs/sql/mysql.sql` as well.

Upgrading tables
----------------

The easiest way to upgrade database structure is to backup old one and start
with creating new one based on example above.

For upgrading existing database, you can use changes described in
:ref:`smsd-tables-history` and then manually update ``Version`` field in
``gammu`` table.