summaryrefslogtreecommitdiffstats
path: root/doc/appendix/files/mysql.txt
blob: ae4a1450b33b47588b72124c34133be9010d587c (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
.. -*- mode: rst -*-

.. _getting_started-mysql:

.. Author: Patrick Ruckstuhl

Mysql example
=============

I had some time ago to continue with putting my configuration into 
Bcfg2 and maybe this helps someone else.

I added a new bundle:

.. code-block:: xml

    <Bundle name="mysql-server" version="3.0">
       <ConfigFile name="/root/bcfg2-install/mysql/users.sh"/>
       <ConfigFile name="/root/bcfg2-install/mysql/users.sql"/>
       <PostInstall name="/root/bcfg2-install/mysql/users.sh"/>
       <Package name="mysql-server-4.1"/>
       <Service name="mysql"/>
    </Bundle>

The ``users.sh`` script looks like this:

.. code-block:: sh

    #!/bin/sh

    mysql --defaults-extra-file=/etc/mysql/debian.cnf mysql \
        < /root/bcfg2-install/mysql/users.sql

On debian there is a user account in ``/etc/mysql/debian.cnf`` 
automatically created, but you could also (manually) create a 
user in the database that has enough permissions and add the 
login information in a file yourself. This file looks like this:

.. code-block:: sh

    [client]
    host     = localhost
    user     = debian-sys-maint
    password = XXXXXXXXXX

The ``users.sql`` looks like this:

.. code-block:: sh

    DELETE FROM db;
    INSERT INTO db VALUES ('localhost', 'phpmyadmin', 'pma', 'Y', 'Y',
    'Y', 'Y', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N');

    DELETE FROM user WHERE User <> 'debian-sys-maint';
    INSERT INTO user VALUES ('localhost', 'root', 'XXXXXXXXXXX', 'Y', 'Y',
    'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y',
    'Y', 'Y', 'Y', 'Y', 'Y', '', '', '', '', 0, 0, 0);
    INSERT INTO user VALUES ('localhost', 'pma', '', 'N', 'N', 'N', 'N',
    'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N',
    'N', 'N', 'N', '', '', '', '', 0, 0, 0);

    FLUSH PRIVILEGES;