|
@@ -144,6 +144,24 @@ function get_mariadb_password {
|
144
|
144
|
fi
|
145
|
145
|
}
|
146
|
146
|
|
|
147
|
+function mariadb_fix_authentication {
|
|
148
|
+ # See http://www.pontikis.net/blog/debian-9-stretch-rc3-web-server-setup-php7-mariadb
|
|
149
|
+ # https://mariadb.com/kb/en/mariadb/unix_socket-authentication-plugin
|
|
150
|
+ function_check run_query
|
|
151
|
+ run_query_root mysql "update mysql.user set plugin = '' where User='root'; flush privileges;"
|
|
152
|
+ run_query_root mysql "UPDATE user SET Password=PASSWORD('$MARIADB_PASSWORD') where USER='root'; flush privileges;"
|
|
153
|
+
|
|
154
|
+ sed -i 's| --skip-grant-tables||g' /lib/systemd/system/mariadb.service
|
|
155
|
+ systemctl daemon-reload
|
|
156
|
+ systemctl restart mariadb
|
|
157
|
+}
|
|
158
|
+
|
|
159
|
+function mariadb_create_root_user {
|
|
160
|
+ run_query mysql "CREATE USER 'root@localhost' IDENTIFIED BY '${MARIADB_PASSWORD}'; flush privileges;"
|
|
161
|
+ run_query mysql "update mysql.user set plugin = '' where User='root@localhost'; flush privileges;"
|
|
162
|
+ run_query mysql "GRANT ALL PRIVILEGES ON * TO 'root@localhost'; flush privileges;"
|
|
163
|
+}
|
|
164
|
+
|
147
|
165
|
function install_mariadb {
|
148
|
166
|
if [[ $(is_completed $FUNCNAME) == "1" ]]; then
|
149
|
167
|
return
|
|
@@ -151,6 +169,8 @@ function install_mariadb {
|
151
|
169
|
apt-get -yq install software-properties-common debconf-utils
|
152
|
170
|
apt-get -yq update
|
153
|
171
|
|
|
172
|
+ remove_watchdog_daemon mariadb
|
|
173
|
+
|
154
|
174
|
function_check get_mariadb_password
|
155
|
175
|
get_mariadb_password
|
156
|
176
|
if [ ! $MARIADB_PASSWORD ]; then
|
|
@@ -185,24 +205,13 @@ function install_mariadb {
|
185
|
205
|
systemctl daemon-reload
|
186
|
206
|
systemctl restart mariadb
|
187
|
207
|
|
188
|
|
- # See http://www.pontikis.net/blog/debian-9-stretch-rc3-web-server-setup-php7-mariadb
|
189
|
|
- # https://mariadb.com/kb/en/mariadb/unix_socket-authentication-plugin
|
190
|
|
-
|
191
|
|
- function_check run_query
|
192
|
|
- run_query_root mysql "update mysql.user set plugin = '' where User='root'; flush privileges;"
|
193
|
|
- run_query_root mysql "UPDATE user SET Password=PASSWORD('$MARIADB_PASSWORD') where USER='root'; flush privileges;"
|
194
|
|
-
|
195
|
|
- sed -i 's| --skip-grant-tables||g' /lib/systemd/system/mariadb.service
|
196
|
|
- systemctl daemon-reload
|
197
|
|
- systemctl restart mariadb
|
|
208
|
+ mariadb_fix_authentication
|
198
|
209
|
|
199
|
210
|
# mariadb daemon seems to occasionally crash
|
200
|
211
|
# This is a crude attempt to keep it running
|
201
|
212
|
add_watchdog_daemon mariadb
|
202
|
213
|
|
203
|
|
- run_query mysql "CREATE USER 'root@localhost' IDENTIFIED BY '${MARIADB_PASSWORD}'; flush privileges;"
|
204
|
|
- run_query mysql "update mysql.user set plugin = '' where User='root@localhost'; flush privileges;"
|
205
|
|
- run_query mysql "GRANT ALL PRIVILEGES ON * TO 'root@localhost'; flush privileges;"
|
|
214
|
+ mariadb_create_root_user
|
206
|
215
|
|
207
|
216
|
mark_completed $FUNCNAME
|
208
|
217
|
}
|