系列文章目录
数据库密码的破解5数据库密码的破解
一、更改密码(知道原始密码)
[root@server15 mysql]# mysqladmin -uroot -p password
Enter password:
New password:
Confirm new password:
二、更改密码(不知道原先密码)
1.跳过授权表进入数据库
[root@server15 mysql]# mysqld_safe --skip-grant-tables &
跳过授权表打开数据库 &后台运行
[2] 5479
[root@server15 mysql]# 210726 18:12:13 mysqld_safe Logging to '/var/log/mariadb/mariadb.log'.
210726 18:12:13 mysqld_safe A mysqld process already exists
[root@server15 mysql]# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 1
Server version: 5.5.60-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)]>
2.修改密码
3.更改里面的这个字段
MariaDB [(none)]> UPDATE mysql.user SET authentication_string=password('123') WHERE User='root';rhel8
MariaDB [(none)]> UPDATE mysql.user SET Password=password('123') WHERE User='root'; rhel7
4.查看mysql的所有进程并且关闭掉
[root@server15 mysql]# ps aux | grep mysql
root 5297 0.0 0.1 113312 1632 pts/0 S 18:10 0:00 /bin/sh /usr/bin/mysqld_safe --skip-grant-tables
mysql 5455 0.0 8.6 970848 88272 pts/0 Sl 18:10 0:00 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --skip-grant-tables --log-error=/var/log/mariadb/mariadb.log --pid-file=/var/run/mariadb/mariadb.pid --socket=/var/lib/mysql/mysql.sock
root 5620 0.0 0.0 112708 972 pts/0 R+ 18:20 0:00 grep --color=auto mysql
[root@server15 mysql]# kill -9 5297
[root@server15 mysql]# kill -9 5455
ps aux | grep mysql
root 5624 0.0 0.0 112708 976 pts/0 R+ 18:22 0:00 grep --color=auto mysql 这个是grep的进程
5.更改完成
[root@server15 mysql]# systemctl start mariadb.service
[root@server15 mysql]# mysql -uroot -p123
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.60-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)]>
END