#
# shell script to grant privileges to the bacula database
#
-# Copyright (C) 2000-2015 Kern Sibbald
+# Copyright (C) 2000-2016 Kern Sibbald
# License: BSD 2-Clause; see file LICENSE-FOSS
#
db_user=${db_user:-@db_user@}
ssl_options="require $db_ssl_options"
fi
+if $bindir/mysql $* -u root -f 2>/dev/null 1>/dev/null <<EOD
+use mysql;
+create user ${db_user} ${pass};
+EOD
+then
+ echo "Created MySQL database user: ${db_user}"
+fi
+
if $bindir/mysql $* -u root -f <<END-OF-DATA
use mysql
grant all privileges on ${db_name}.* to ${db_user}@localhost ${pass} ${ssl_options};