This commit is contained in:
Bob Mottram 2017-06-25 10:06:24 +01:00
parent de8e808e99
commit 45be6e2915
1 changed files with 22 additions and 13 deletions

View File

@ -144,6 +144,24 @@ function get_mariadb_password {
fi fi
} }
function mariadb_fix_authentication {
# See http://www.pontikis.net/blog/debian-9-stretch-rc3-web-server-setup-php7-mariadb
# https://mariadb.com/kb/en/mariadb/unix_socket-authentication-plugin
function_check run_query
run_query_root mysql "update mysql.user set plugin = '' where User='root'; flush privileges;"
run_query_root mysql "UPDATE user SET Password=PASSWORD('$MARIADB_PASSWORD') where USER='root'; flush privileges;"
sed -i 's| --skip-grant-tables||g' /lib/systemd/system/mariadb.service
systemctl daemon-reload
systemctl restart mariadb
}
function mariadb_create_root_user {
run_query mysql "CREATE USER 'root@localhost' IDENTIFIED BY '${MARIADB_PASSWORD}'; flush privileges;"
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;"
}
function install_mariadb { function install_mariadb {
if [[ $(is_completed $FUNCNAME) == "1" ]]; then if [[ $(is_completed $FUNCNAME) == "1" ]]; then
return return
@ -151,6 +169,8 @@ function install_mariadb {
apt-get -yq install software-properties-common debconf-utils apt-get -yq install software-properties-common debconf-utils
apt-get -yq update apt-get -yq update
remove_watchdog_daemon mariadb
function_check get_mariadb_password function_check get_mariadb_password
get_mariadb_password get_mariadb_password
if [ ! $MARIADB_PASSWORD ]; then if [ ! $MARIADB_PASSWORD ]; then
@ -185,24 +205,13 @@ function install_mariadb {
systemctl daemon-reload systemctl daemon-reload
systemctl restart mariadb systemctl restart mariadb
# See http://www.pontikis.net/blog/debian-9-stretch-rc3-web-server-setup-php7-mariadb mariadb_fix_authentication
# https://mariadb.com/kb/en/mariadb/unix_socket-authentication-plugin
function_check run_query
run_query_root mysql "update mysql.user set plugin = '' where User='root'; flush privileges;"
run_query_root mysql "UPDATE user SET Password=PASSWORD('$MARIADB_PASSWORD') where USER='root'; flush privileges;"
sed -i 's| --skip-grant-tables||g' /lib/systemd/system/mariadb.service
systemctl daemon-reload
systemctl restart mariadb
# mariadb daemon seems to occasionally crash # mariadb daemon seems to occasionally crash
# This is a crude attempt to keep it running # This is a crude attempt to keep it running
add_watchdog_daemon mariadb add_watchdog_daemon mariadb
run_query mysql "CREATE USER 'root@localhost' IDENTIFIED BY '${MARIADB_PASSWORD}'; flush privileges;" mariadb_create_root_user
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;"
mark_completed $FUNCNAME mark_completed $FUNCNAME
} }