### 一大早数据库被黑，之前数据都没了:sob: ![1269217401.png](https://blog.cnccy.com/usr/uploads/2021/11/2014165706.png) * 1、数据库备份 敲黑板！！！ * 2、开启binlog日志 * 2.1登录MySQL后，输入show variables like '%log_bin%'；查看到binlog日志为OFF关闭状态; ![](http://blog.cnccy.com/usr/uploads/2021/08/2080145521.png) * 2.2开启binlog 修改MySQL配置文件my.cnf，加入如下两行 ``` [root@localhost ~]# vim /usr/local/mysql/my.cnf server-id = 1 log_bin = /data/mysql/mysql-bin ``` * 2.3重启让配置生效 ``` [root@localhost ~]# /etc/init.d/mysqld restart Shutting down MySQL.. SUCCESS! Starting MySQL. SUCCESS! ``` * 3、更换超级复杂的mysql密码 * 4、更换mysql端口号 ``` [root@localhost ~]# vim /usr/local/mysql/my.cnf [mysqld] port = 3389 [root@localhost ~]# /etc/init.d/mysqld restart Shutting down MySQL.. SUCCESS! Starting MySQL. SUCCESS! [root@localhost ~]# ``` * 5、禁止mysql远程访问