DROP DATABASE IF EXISTS sog;
-- Create the new database
CREATE DATABASE sog;
-- Select it and start adding the tables etc
USE sog;

/* Creat the admin user used for database recovery */
GRANT ALL ON *.* TO 'admin'@'localhost' IDENTIFIED BY 'admin' WITH GRANT OPTION;
GRANT ALL ON *.* TO 'admin'@'%' IDENTIFIED BY 'admin' WITH GRANT OPTION;

/* Create the replication user */
GRANT REPLICATION SLAVE ON *.* TO 'replicator'@'localhost' IDENTIFIED BY 'replicator';
GRANT REPLICATION SLAVE ON *.* TO 'replicator'@'%' IDENTIFIED BY 'replicator';

/* User used to ping the server */
GRANT SELECT ON *.* TO 'ping'@'localhost' IDENTIFIED BY 'pong';
GRANT SELECT ON *.* TO 'ping'@'%' IDENTIFIED BY 'pong';

/* Create the GIS user */
/* Grant temporary tables and drop privileges as hibernate uses these */
GRANT SELECT,UPDATE,INSERT,DELETE,CREATE TEMPORARY TABLES,DROP ON *.* TO 'gis'@'localhost' IDENTIFIED BY 'gis';
GRANT SELECT,UPDATE,INSERT,DELETE,CREATE TEMPORARY TABLES,DROP ON *.* TO 'gis'@'%' IDENTIFIED BY 'gis';

FLUSH PRIVILEGES;
