最近有一个小站被恶意发帖,导致大量灌水。于是,索性对小站做一次全面排查。想到很久没有修改 MySQL 数据库的 root 密码了,立马行动!找了下资料,并亲自测试,其实就两条命令:
wget http://soft.vpser.net/lnmp/ext/reset_mysql_root_password.sh
sh reset_mysql_root_password.sh
[root@HQW-Aliyun ~]# wget http://soft.vpser.net/lnmp/ext/reset_mysql_root_password.sh --2023-09-10 16:51:53-- http://soft.vpser.net/lnmp/ext/reset_mysql_root_password.sh Resolving soft.vpser.net... 81.70.180.148 Connecting to soft.vpser.net|81.70.180.148|:80... connected. HTTP request sent, awaiting response... 302 Moved Temporarily Location: https://soft.lnmp.com/lnmp/ext/reset_mysql_root_password.sh [following] --2023-09-10 16:51:53-- https://soft.lnmp.com/lnmp/ext/reset_mysql_root_password.sh Resolving soft.lnmp.com... 8.217.207.197 Connecting to soft.lnmp.com|8.217.207.197|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 2464 (2.4K) [application/octet-stream] Saving to: a€?reset_mysql_root_password.sha€? 100%[===============================================>] 2,464 --.-K/s in 0s 2023-09-10 16:51:54 (236 MB/s) - a€?reset_mysql_root_password.sha€? saved [2464/2464] [root@HQW-Aliyun ~]# sh reset_mysql_root_password.sh +-------------------------------------------------------------------+ | Reset MySQL/MariaDB root Password for LNMP, Written by Licess | +-------------------------------------------------------------------+ | A tool to reset MySQL/MariaDB root password for LNMP | +-------------------------------------------------------------------+ | For more information please visit https://lnmp.org | +-------------------------------------------------------------------+ | Usage: ./reset_mysql_root_password.sh | +-------------------------------------------------------------------+ Enter New mysql root password: xxxxxxxxxxxxx Stoping mysql... Shutting down MySQL. SUCCESS! Starting mysql with skip grant tables update mysql root password... Password reset succesfully. Now killing mysqld softly Restarting the actual mysql service Starting MySQL.. SUCCESS! Password successfully reset to 'xxxxxxxxxxxxx' [root@HQW-Aliyun ~]# q