fixed mysql_database type

can now install a database, and create a user who manages that database
This commit is contained in:
Benedikt Koeppel 2012-02-18 23:10:56 +01:00
parent cfaee39e70
commit c67c0cf12d

View file

@ -26,9 +26,11 @@ else # otherwise use the object id as database name
database="$__object_id" database="$__object_id"
fi fi
mysql -u root -p <<-EOF cat <<-EOFF
mysql -u root <<-EOF
CREATE DATABASE IF NOT EXISTS $database CREATE DATABASE IF NOT EXISTS $database
EOF EOF
EOFF
# if --user was specified # if --user was specified
if [ -f "$__object/parameter/user" ]; then if [ -f "$__object/parameter/user" ]; then
@ -37,12 +39,17 @@ if [ -f "$__object/parameter/user" ]; then
# if --password was specified # if --password was specified
if [ -f "$__object/parameter/password" ]; then if [ -f "$__object/parameter/password" ]; then
password="$(cat "$__object/parameter/password")" password="$(cat "$__object/parameter/password")"
mysql -u root -p <<-EOF cat <<-EOFF
mysql -u root <<-EOF
GRANT ALL PRIVILEGES ON $database.* to '$user'@'localhost' IDENTIFIED BY '$password'; GRANT ALL PRIVILEGES ON $database.* to '$user'@'localhost' IDENTIFIED BY '$password';
EOF EOF
EOFF
else else
mysql -u root -p <<-EOF password=""
cat <<-EOFF
mysql -u root <<-EOF
GRANT ALL PRIVILEGES ON $database.* to '$user'@'localhost'; GRANT ALL PRIVILEGES ON $database.* to '$user'@'localhost';
EOF EOF
EOFF
fi fi
fi fi