Bläddra i källkod

Fixing mariadb brokenness

Bob Mottram 8 år sedan
förälder
incheckning
ad5957d796
1 ändrade filer med 18 tillägg och 8 borttagningar
  1. 18
    8
      src/freedombone-utils-database

+ 18
- 8
src/freedombone-utils-database Visa fil

153
     fi
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
 function mariadb_fix_authentication {
166
 function mariadb_fix_authentication {
157
     # See http://www.pontikis.net/blog/debian-9-stretch-rc3-web-server-setup-php7-mariadb
167
     # 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
168
     # https://mariadb.com/kb/en/mariadb/unix_socket-authentication-plugin
159
     remove_watchdog_daemon mariadb
169
     remove_watchdog_daemon mariadb
160
-    systemctl stop mariadb
170
+    mariadb_kill_stone_dead
161
     mysqld_safe --skip-grant-tables &
171
     mysqld_safe --skip-grant-tables &
162
-    output=$(mysql -u root << EOF
172
+    sleep 5
173
+    mysql -u root --password="$MARIADB_PASSWORD" << EOF
163
 use mysql;
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
 EOF
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
     sed -i 's| --skip-grant-tables||g' /lib/systemd/system/mariadb.service
181
     sed -i 's| --skip-grant-tables||g' /lib/systemd/system/mariadb.service
172
     systemctl daemon-reload
182
     systemctl daemon-reload
173
-    systemctl restart mariadb
183
+    systemctl start mariadb
174
     add_watchdog_daemon mariadb
184
     add_watchdog_daemon mariadb
175
 }
185
 }
176
 
186