Преглед на файлове

Improve the fixing of mariadb authentication

Bob Mottram преди 7 години
родител
ревизия
92b9828bf6
променени са 1 файла, в които са добавени 12 реда и са изтрити 7 реда
  1. 12
    7
      src/freedombone-utils-database

+ 12
- 7
src/freedombone-utils-database Целия файл

@@ -156,13 +156,22 @@ function get_mariadb_password {
156 156
 function mariadb_fix_authentication {
157 157
     # See http://www.pontikis.net/blog/debian-9-stretch-rc3-web-server-setup-php7-mariadb
158 158
     # https://mariadb.com/kb/en/mariadb/unix_socket-authentication-plugin
159
-    function_check run_query
160
-    run_query_root mysql "update mysql.user set plugin = '' where User='root'; flush privileges;"
161
-    run_query_root mysql "UPDATE user SET Password=PASSWORD('$MARIADB_PASSWORD') where USER='root'; flush privileges;"
159
+    remove_watchdog_daemon mariadb
160
+    systemctl stop mariadb
161
+    mysqld_safe --skip-grant-tables &
162
+    output=$(mysql -u root << EOF
163
+use mysql;
164
+update mysql.user set plugin = '' where User='root'; flush privileges;
165
+UPDATE user SET Password=PASSWORD('$MARIADB_PASSWORD') where USER='root'; flush privileges;
166
+EOF
167
+)
168
+    kill_pid=$(ps aux | grep mysql | awk -F ' ' '{print $2}' | head -n 1)
169
+    kill -9 $kill_pid
162 170
 
163 171
     sed -i 's| --skip-grant-tables||g' /lib/systemd/system/mariadb.service
164 172
     systemctl daemon-reload
165 173
     systemctl restart mariadb
174
+    add_watchdog_daemon mariadb
166 175
 }
167 176
 
168 177
 function mariadb_create_root_user {
@@ -216,10 +225,6 @@ function install_mariadb {
216 225
 
217 226
     mariadb_fix_authentication
218 227
 
219
-    # mariadb daemon seems to occasionally crash
220
-    # This is a crude attempt to keep it running
221
-    add_watchdog_daemon mariadb
222
-
223 228
     mariadb_create_root_user
224 229
 
225 230
     mark_completed $FUNCNAME