之前使用腾讯云服务器,数据库使用的是默认端口3306,密码设的很简单,然后就被一个境外ip给暴力破解了,里面一万五千多条数据没了,我之前也没做备份,自己没能找回来。
后来就先把密码端口改了,然后配置一下binlog日志以防万一,在此记录一下配置,方便下次查阅。
ps:改完配置要重启mysql服务,没报错就是开启了。
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
[mysqld]
port=3360 #之前用3306被境外ip破解了
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
server-id=1 #不加这个会报错
log-bin=mysql-log #这里我加前缀/var/log/mysql老报错,就直接不加了,目录不是这个
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
修改后可以登录mysql查看相关内容:
其中log_bin显示开启,下面是日志所在的目录。