浏览代码

Set mariadb password

Bob Mottram 7 年前
父节点
当前提交
45df6aad24
共有 1 个文件被更改,包括 8 次插入4 次删除
  1. 8
    4
      src/freedombone-utils-database

+ 8
- 4
src/freedombone-utils-database 查看文件

@@ -162,16 +162,20 @@ function install_mariadb {
162 162
         exit 34672
163 163
     fi
164 164
 
165
-    #if [ ! -f /etc/mysql/conf.d/my.cnf ]; then
166
-    #    echo $'/etc/mysql/conf.d/my.cnf not found'
167
-    #    exit 6376245
168
-    #fi
165
+    sed -i 's|ExecStart=/usr/sbin/mysqld|ExecStart=/usr/sbin/mysqld --skip-grant-tables|g' /lib/systemd/system/mariadb.service
166
+    systemctl daemon-reload
169 167
     systemctl restart mariadb
170 168
 
171 169
     # See http://www.pontikis.net/blog/debian-9-stretch-rc3-web-server-setup-php7-mariadb
172 170
     # https://mariadb.com/kb/en/mariadb/unix_socket-authentication-plugin
171
+
173 172
     function_check run_query
174 173
     run_query_root mysql "update mysql.user set plugin = '' where User='root'; flush privileges;"
174
+    run_query_root mysql "UPDATE user SET Password=PASSWORD('$MARIADB_PASSWORD') where USER='root'; flush privileges;"
175
+
176
+    sed -i 's| --skip-grant-tables||g' /lib/systemd/system/mariadb.service
177
+    systemctl daemon-reload
178
+    systemctl restart mariadb
175 179
 
176 180
     mysqladmin -u root password "$MARIADB_PASSWORD"
177 181
     mark_completed $FUNCNAME