23天数据库空了。

之前就是这个halo,是别人写好的jar,有具体的部署方法,跟着来,然后就在服务器上发布了,记了好多东西,然后心痛。
没有备份,binlog也没有开启。直接就是恢复不了了。

Linux上yum安装方式

   wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm

   yum -y install mysql57-community-release-el7-10.noarch.rpm

   yum -y install mysql-community-server

MySQL基本操作

  启动 
  systemctl start  mysqld.service
  关闭
  systemctl stop  mysqld.service
  重启
  systemctl restart  mysqld.service
  查看状态
  systemctl status  mysqld.service
  查看mysql是否运行
  ps -ef|grep mysqld

MySQL修改密码策略

通过命令方式修改mysql重启后,恢复默认的状态。需要直接修改配置文件

  vi /etc/my.cnf
  SHOW VARIABLES LIKE 'validate_password%';    查看策略

下面列出我的配置文件,复制直接替换文件就行了

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html

[mysqld]
#
# 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.

# 定期清理
expire_logs_days = 15

# 日志位置
server-id = 1

log_bin=/var/lib/mysql/mysql-bin
#
# 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

bind-address=0.0.0.0
port=3306

# 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
symbolic-links=0
max_connections=600
innodb_file_per_table=1
lower_case_table_names=1

validate_password_policy=0
validate_password_length=4
# skip_grant_tables
  1. binlog记录一段时间对数据库的操作
查看日志开启状态           					
show variables like 'log_%';
查看所有binlog日志列表     					
show master logs;
查看最新一个binlog日志的编号名称,及其最后一个操作事件结束点 	
show master status;
刷新log日志,立刻产生一个新编号的binlog日志文件,跟重启一个效果   
flush logs;
清空所有binlog日志
reset master;

日志查看,因为是二进制文件没法用vi等打开,可以用mysql的mysqlbinlog打开

离奇事件

昨天晚上数据库又出现使用navlact连接不上的问题了,报错1045(拒绝连接),特别好奇,不知道到底是啥原因。然后我去服务器上面登录mysql,密码也没有问题,做了一些操作如下。

 连接MySQL    
  	mysql -u root -p
 退出   
 	quit
 查看密码策略,实际上是登录了这个mysql数据库,然后做了一些查询而已
    	SHOW VARIABLES LIKE 'validate_password%';
 执行了一段祖传代码,我也不知道啥原因,执行之后就可以用工具连接了,配置文件中直接配置?直接这样修改会重置?
 	GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;
 刷新权限
  	flush privileges;

在这里插入图片描述
被攻击了,我想着可能是因为密码太过简单,被猜出来了,然后服务器端口也是全部开放了,我一想,不服呀,自己数据库居然还要我联系他,卸载重来,一气之下卸载了,它上面写着能够恢复数据,我也不知道是不是真的,如果是能够恢复,只有两种可能,通过binlog去恢复,或者硬件方面考虑······。
卸载充满,没有去binlog日志验证。

数据库卸载

 查看已安装的mysql
 rpm -qa | grep -i mysql
 卸载
 yum remove      所有能查看到的包。
 删除对应文件目录
 find / -name mysql
 rm -rf  依次删除

MySQL数据库备份

  1. 手动备份
  2. 自动化脚本
    暂留

主从同步

转载:主从实战
这里暂留。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值