# $Id: create_db2.mysql,v 1.1 2007-01-26 12:59:05 mike Exp $
# Creates the database and users for openurl
#
# Create the database as follows:
#	mysql -u root -p < create_db.mysql
# (and enter the Mysql root password when prompted)
#
# After that, run create_tables as follows:
#   mysql -u kr_admin -p kr_adm_3636 < create_tables.mysql
#

drop database if exists kr2;
create database kr2;
use kr2;

GRANT USAGE ON kr2 . * TO "kr_read"@"localhost" IDENTIFIED BY "kr_read_3636" ;
GRANT USAGE ON kr2 . * TO "kr_admin"@"localhost" IDENTIFIED BY "kr_adm_3636" ;

# With MySQL version 12.22 Distrib 4.0.23, as including in Ubuntu
# Linux Hoary Hedgehog, the REVOKE command stupidly fails if there are
# no privileges defined.  Nice one, MySQL.  So we have to add a
# vacuous privilege first, just so we can be sure of being able to do
# the REVOKE.  Sigh.
#
GRANT SELECT ON `kr2`.* TO "kr_read"@"localhost";
REVOKE ALL PRIVILEGES ON `kr2`.* FROM "kr_read"@"localhost";
GRANT SELECT 
  ON `kr2`.* TO "kr_read"@"localhost";

GRANT SELECT ON `kr2`.* TO "kr_admin"@"localhost";
REVOKE ALL PRIVILEGES ON `kr2`.* FROM "kr_admin"@"localhost";
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER 
  ON `kr2`.* TO "kr_admin"@"localhost";


