Sophie

Sophie

distrib > Fedora > 17 > i386 > media > updates > by-pkgid > b50d8ee6d7871fcc13c0677a9364ed59 > files > 69

bcfg2-doc-1.3.0-1.fc17.noarch.rpm

.. -*- mode: rst -*-

.. _appendix-files-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">
       <Path name="/root/bcfg2-install/mysql/users.sh"/>
       <Path 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::

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

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

    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;