破解Mariadb数据库root密码
先停止Mariadb服务:
systemctl stop mariadb
找并运行 mysqld_safe 程序绕开 MariaDB5.5 数据库密码验证
[root@localhost ~]# find / -name mysqld_safe
/usr/bin/mysqld_safe
[root@localhost ~]# /usr/bin/mysqld_safe --skip-grant-tables &
我们再打开一个ssh终端,直接使用 mysql 命令登录 MariaDB5.5 数据库并修改 root 登录密码
[root@localhost ~]# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 1
Server version: 5.5.65-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
MariaDB [mysql]> UPDATE user SET password=password("填写新的数据库密码") WHERE user='root';
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3 Changed: 3 Warnings: 0
MariaDB [mysql]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
MariaDB [mysql]> exit
Bye
启动Mariadb服务:
systemctl start mariadb
如果启动失败,就直接重启服务器试试即可。