How to bootstrap PostgreSQL and MySQL for EMdF
Ulrik Petersen
Created: 3/6-2001 (March 6, 2001)
Last update: 10/30-2006


What's this?
============

If you are using PostgreSQL or MySQL, you may need to create a
database user account just to get started.  These notes take you
through this process.

If you are using SQLite, then read no further.  You don't have to
create any user or database.


Introduction
============

If you use MySQL or PostgreSQL, and you do not already have a database
user account set up for using your backend, then these notes take you
through the process.

If you already have a database user account, you don't need to worry
about setting up another one.  You can just use that username when
using Emdros.

However, the default username used by all the programs is "emdf".  If
you want a little extra convenience, you can create this user using
the steps detailed below.  Then you won't have to tell each program on
the command line which username to use.  This is optional: You can use
any valid database user account, so long as you give the right
password.

It used to be (before Emdros version 1.2.0.pre52) that you *had* to
create an "emdf" database.  As of 1.2.0.pre52, this is no longer the
case.

Below I describe how to set up Emdros with a user called "emdf".



Bootstrapping MySQL
===================

The user 'emdf' can be created with mysql as follows:

1. On Unix, become root.  On Windows, you may need to log in as the
   Administrator.

2. Then use the following command (on Unix):

   % mysql

   On Windows: 

   C:\mysql\bin> mysql -u root


3. Once you are inside the mysql shell, issue the following two
   queries:


mysql> GRANT ALL PRIVILEGES ON *.* TO emdf@localhost
       IDENTIFIED BY 'changeme' WITH GRANT OPTION;

mysql> GRANT ALL PRIVILEGES ON *.* TO emdf@"%"
       IDENTIFIED BY 'changeme' WITH GRANT OPTION;

   Apparently, one must issue both of these commands.

   If you don't wish to give that much power to the user, then please
   read the MySQL documentation for how to grant less.  The user used
   for Emdros must at least be allowed to create new databases.

   You should also change the password to something other than
   "changeme".

4. Leave the mysql prompt by typing

   quit

   and pressing "Enter".

   If this doesn't work, press Ctrl-D (on Unix/Linux) or Ctrl-Z (on
   Windows).



Bootstrapping PostgreSQL
========================

1. Login as the user that runs the postmaster.  This is done
   differently depending on what operating system you are using.

    - On Unix/Linux:

      - become root
      $ su postgres

    - On Mac OS X:

      - Nothing to be done in this step.

    - On Windows NT/2000/XP:

      - If postmaster runs as a service: Log in as the user owning the
        service, or Administrator if none.

      - If postmaster does not run as a service, but is run by the
        current user, then remain that user (don't login/logout).

2.  - On Mac OS X:

      $ sudo -u postgres createuser -P emdf

    - On all other operating systems:

      $ createuser -P emdf

    The user should be allowed to create new DBs, and it is best if
    the user can also create new users.  This will prevent the MQL
    statement "VACUUM DATABASE" from issuing warnings about the emdf
    user not owning certain tables.

    The -P option gives you the opportunity to give the emdf user a
    password.

3.  Create the emdf database.  This step is optional, but may be
    beneficial, e.g., if you want to run the psql shell as the emdf
    user and forget to give psql the -d switch.

    - On Mac OS X:

      $ sudo -u postgres createdb -U emdf emdf

    - On all other operating systems:

      $ createdb -U emdf emdf

Note that you may have to change the PostgreSQL configuration in the
file pg_hba.conf.  Search for this file and change the default
authentication method if you get errors about not being able to
authenticate.  This is also described in the HOW-TO-USE document.

Summary (also found in HOW-TO-USE):

In order to bootstrap, you may have to change the authentication in
pg_hba.conf to:

    local       all     all       trust

But you should probably only do this temporarily while you create the
emdf user.  After you have created the emdf user (or whatever user you
want), you can change the method back to 'password', as detailed in
the HOW-TO-USE document.
