为什么暴力呢?因为通过以下方式,任何人,只需要知道端口,ip就能连接到你的MySQL,所以保证外部不能连接非常重要
下列方式选择一种即可
修改my.cnf配置文件,在[mysqld]的段中加上:skip-grant-tables,如:
vi /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
skip-grant-tables
service mysqld reset
或 /etc/init.d/mysqld restart
# /usr/bin/mysql
mysql> USE mysql ;
mysql> UPDATE user SET Password = password ( 'moell.cn' ) WHERE User = 'root' ;
Query OK, 0 rows affected (0.00 sec)
Rows matched: 2 Changed: 0 Warnings: 0
mysql> flush privileges ;
Query OK, 0 rows affected (0.01 sec)
mysql> quit
Bye
新密码设置成功后,还原my.cnf配置,重启MySQL,然后我们就可以继续愉快的玩耍了