/* create_database.sql
 * 2011-06-07
 * by Gernot WALZL
 */

SET @database = 'mydatabase';
SET @username = 'mydatabase';
SET @password = 'password';

SET @sql = CONCAT('CREATE DATABASE IF NOT EXISTS ', @database);
PREPARE stmt FROM @sql; EXECUTE stmt;

SET @sql = CONCAT('CREATE USER \'',@username,'\'@\'localhost\' IDENTIFIED BY \'',@password,'\'');
PREPARE stmt FROM @sql; EXECUTE stmt;

SET @sql = CONCAT('GRANT ALL PRIVILEGES ON ',@database,'.* TO \'',@username,'\'@\'localhost\'');
PREPARE stmt FROM @sql; EXECUTE stmt;

/* SET PASSWORD FOR 'username'@'localhost' = PASSWORD('newpass'); */
