Selaa lähdekoodia

Fixing mariadb brokenness

Bob Mottram 7 vuotta sitten
vanhempi
commit
ad5957d796
1 muutettua tiedostoa jossa 18 lisäystä ja 8 poistoa
  1. 18
    8
      src/freedombone-utils-database

+ 18
- 8
src/freedombone-utils-database Näytä tiedosto

@@ -153,24 +153,34 @@ function get_mariadb_password {
153 153
     fi
154 154
 }
155 155
 
156
+function mariadb_kill_stone_dead {
157
+    systemctl stop mariadb
158
+    kill_pid=$(ps aux | grep mysqld_safe | awk -F ' ' '{print $2}' | head -n 1)
159
+    kill -9 $kill_pid
160
+    kill_pid=$(ps aux | grep mysqld | awk -F ' ' '{print $2}' | head -n 1)
161
+    kill -9 $kill_pid
162
+    kill_pid=$(ps aux | grep mysqld | awk -F ' ' '{print $2}' | head -n 1)
163
+    kill -9 $kill_pid
164
+}
165
+
156 166
 function mariadb_fix_authentication {
157 167
     # See http://www.pontikis.net/blog/debian-9-stretch-rc3-web-server-setup-php7-mariadb
158 168
     # https://mariadb.com/kb/en/mariadb/unix_socket-authentication-plugin
159 169
     remove_watchdog_daemon mariadb
160
-    systemctl stop mariadb
170
+    mariadb_kill_stone_dead
161 171
     mysqld_safe --skip-grant-tables &
162
-    output=$(mysql -u root << EOF
172
+    sleep 5
173
+    mysql -u root --password="$MARIADB_PASSWORD" << EOF
163 174
 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;
175
+update mysql.user set plugin = '' where User='root';
176
+UPDATE user SET Password=PASSWORD('$MARIADB_PASSWORD') where USER='root';
177
+flush privileges;
166 178
 EOF
167
-)
168
-    kill_pid=$(ps aux | grep mysql | awk -F ' ' '{print $2}' | head -n 1)
169
-    kill -9 $kill_pid
179
+    mariadb_kill_stone_dead
170 180
 
171 181
     sed -i 's| --skip-grant-tables||g' /lib/systemd/system/mariadb.service
172 182
     systemctl daemon-reload
173
-    systemctl restart mariadb
183
+    systemctl start mariadb
174 184
     add_watchdog_daemon mariadb
175 185
 }
176 186