標籤:read node art lib 密碼串連 pre exec ;; 參考
環境背景:CentOS 7.2
| 一、編輯/usr/lib/systemd/system/mariadb.service 檔案,在Service段中添加 |
| 123456789101112 |
[Service]Type=simpleUser=mysqlGroup=mysqlUser=mysqlGroup=mysql ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n# Note: we set --basedir to prevent probes that might trigger SELinux alarms,# per bug #547485#在Server段中的ExecStart出添加如下ExecStart=/usr/bin/mysqld_safe --basedir=/usr --skip-grant-tables --skip-networking |
|
二、鍵入systemctl daemon-reload使其立即生效 |
| 1 |
[[email protected] ~]# systemctl daemon-reload |
| 三、重新啟動mariadb服務並使用mysql聯入 |
| 1234567891011 |
[[email protected] ~]# systemctl restart mariadb.service[[email protected] ~]# mysqlWelcome to the MariaDB monitor. Commands end with ; or \g.Your MariaDB connection id is 2Server version: 5.5.44-MariaDB MariaDB Server Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others. Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement. MariaDB [(none)]> |
| 123456 |
MariaDB [(none)]> UPDATE mysql.user SET Password=PASSWORD(‘xiaoshui‘) WHERE user=‘root‘ and host=‘localhost‘;Query OK, 0 rows affected (0.00 sec)Rows matched: 1 Changed: 0 Warnings: 0 MariaDB [(none)]> FLUSH PRIVILEGES;Query OK, 0 rows affected (0.00 sec) |
| 五、退出並關閉mariadb服務並把/usr/lib/systemd/system/mariadb.service檔案中剛剛添加的那兩行移除 |
| 12 |
ExecStart=/usr/bin/mysqld_safe --basedir=/usr ExecStartPost=/usr/libexec/mariadb-wait-ready $MAINPID |
| 六、啟動mariadb服務,並使用新設定的密碼串連 |
| 1234567891011 |
[[email protected] ~]# mysql -u root -h localhost -pEnter password: Welcome to the MariaDB monitor. Commands end with ; or \g.Your MariaDB connection id is 4Server version: 5.5.44-MariaDB MariaDB Server Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others. Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement. MariaDB [(none)]> |
參考:http://dashui.blog.51cto.com/11254923/1877042
[轉]Mariadb的root密碼忘記後的解決方案