Don't use mysqladmin
This commit is contained in:
parent
542515be7d
commit
a5fe0462de
|
@ -181,7 +181,6 @@ function install_mariadb {
|
|||
run_query mysql "update mysql.user set plugin = '' where User='root@localhost'; flush privileges;"
|
||||
run_query mysql "GRANT ALL PRIVILEGES ON * TO 'root@localhost'; flush privileges;"
|
||||
|
||||
mysqladmin -u root password "$MARIADB_PASSWORD"
|
||||
mark_completed $FUNCNAME
|
||||
}
|
||||
|
||||
|
@ -259,27 +258,6 @@ quit" > $INSTALL_DIR/batch.sql
|
|||
shred -zu $INSTALL_DIR/batch.sql
|
||||
}
|
||||
|
||||
function create_database {
|
||||
app_name="$1"
|
||||
app_admin_password="$2"
|
||||
app_admin_username=$3
|
||||
if [ ! -d $INSTALL_DIR ]; then
|
||||
mkdir $INSTALL_DIR
|
||||
fi
|
||||
if [ ! $app_admin_username ]; then
|
||||
app_admin_username=${app_name}admin
|
||||
fi
|
||||
echo "create database ${app_name};
|
||||
CREATE USER '$app_admin_username@localhost' IDENTIFIED BY '${app_admin_password}';
|
||||
update mysql.user set plugin = '' where User='$app_admin_username@localhost';
|
||||
GRANT ALL PRIVILEGES ON ${app_name}.* TO '$app_admin_username@localhost';
|
||||
flush privileges;
|
||||
quit" > $INSTALL_DIR/batch.sql
|
||||
chmod 600 $INSTALL_DIR/batch.sql
|
||||
mysql -u root --password="$MARIADB_PASSWORD" < $INSTALL_DIR/batch.sql
|
||||
shred -zu $INSTALL_DIR/batch.sql
|
||||
}
|
||||
|
||||
function initialise_database {
|
||||
database_name=$1
|
||||
database_file=$2
|
||||
|
@ -301,6 +279,28 @@ function run_query_root {
|
|||
mysql -e "$database_query" $database_name
|
||||
}
|
||||
|
||||
function create_database {
|
||||
app_name="$1"
|
||||
app_admin_password="$2"
|
||||
app_admin_username=$3
|
||||
if [ ! -d $INSTALL_DIR ]; then
|
||||
mkdir $INSTALL_DIR
|
||||
fi
|
||||
if [ ! $app_admin_username ]; then
|
||||
app_admin_username=${app_name}admin
|
||||
fi
|
||||
|
||||
echo "create database ${app_name};
|
||||
CREATE USER '$app_admin_username@localhost' IDENTIFIED BY '${app_admin_password}';
|
||||
update mysql.user set plugin = '' where User='$app_admin_username@localhost';
|
||||
GRANT ALL PRIVILEGES ON ${app_name}.* TO '$app_admin_username@localhost';
|
||||
flush privileges;
|
||||
quit" > $INSTALL_DIR/batch.sql
|
||||
chmod 600 $INSTALL_DIR/batch.sql
|
||||
mysql -u root --password="$MARIADB_PASSWORD" < $INSTALL_DIR/batch.sql
|
||||
shred -zu $INSTALL_DIR/batch.sql
|
||||
}
|
||||
|
||||
function run_query_with_output {
|
||||
database_name=$1
|
||||
database_query=$2
|
||||
|
@ -313,11 +313,19 @@ EOF
|
|||
}
|
||||
|
||||
function drop_database {
|
||||
database_name=$1
|
||||
database_name="$1"
|
||||
|
||||
get_mariadb_password
|
||||
mysqladmin -uroot -p"$MARIADB_PASSWORD" -f drop $database_name
|
||||
|
||||
echo "drop database ${app_name};
|
||||
flush privileges;
|
||||
quit" > $INSTALL_DIR/batch.sql
|
||||
chmod 600 $INSTALL_DIR/batch.sql
|
||||
mysql -u root --password="$MARIADB_PASSWORD" < $INSTALL_DIR/batch.sql
|
||||
shred -zu $INSTALL_DIR/batch.sql
|
||||
}
|
||||
|
||||
|
||||
function database_reinstall {
|
||||
apt-get -yq purge mariadb*
|
||||
rm -rf /var/lib/mysql
|
||||
|
|
Loading…
Reference in New Issue