Bläddra i källkod

Improve the fixing of mariadb authentication

Bob Mottram 7 år sedan
förälder
incheckning
92b9828bf6
1 ändrade filer med 12 tillägg och 7 borttagningar
  1. 12
    7
      src/freedombone-utils-database

+ 12
- 7
src/freedombone-utils-database Visa fil

156
 function mariadb_fix_authentication {
156
 function mariadb_fix_authentication {
157
     # See http://www.pontikis.net/blog/debian-9-stretch-rc3-web-server-setup-php7-mariadb
157
     # See http://www.pontikis.net/blog/debian-9-stretch-rc3-web-server-setup-php7-mariadb
158
     # https://mariadb.com/kb/en/mariadb/unix_socket-authentication-plugin
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
     sed -i 's| --skip-grant-tables||g' /lib/systemd/system/mariadb.service
171
     sed -i 's| --skip-grant-tables||g' /lib/systemd/system/mariadb.service
164
     systemctl daemon-reload
172
     systemctl daemon-reload
165
     systemctl restart mariadb
173
     systemctl restart mariadb
174
+    add_watchdog_daemon mariadb
166
 }
175
 }
167
 
176
 
168
 function mariadb_create_root_user {
177
 function mariadb_create_root_user {
216
 
225
 
217
     mariadb_fix_authentication
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
     mariadb_create_root_user
228
     mariadb_create_root_user
224
 
229
 
225
     mark_completed $FUNCNAME
230
     mark_completed $FUNCNAME