mysql log-bin 默认是开启的吗

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql log-bin 默认是开启的吗相关的知识,希望对你有一定的参考价值。

默认是关闭的,只要你在my.cnf里写了该配置,才会有log-bin 参考技术A 注意:
1、开启bin-log,路径要设置在mysql用户所属文件夹下
例如:
log-bin=/home/123/bin-log 123的所属用户就要是Mysql
[root@520 home]# ll
总计 163736
drwxr-xr-x 2 mysql mysql 4096 01-16 16:47 123

140116 15:59:21 mysqld started
140116 15:59:21 [Warning] option 'max_join_size': unsigned value 18446744073709551615 adjusted to 4294967295
140116 15:59:21 [Warning] option 'max_join_size': unsigned value 18446744073709551615 adjusted to 4294967295
/usr/libexec/mysqld: File '/var/lib/mysql.index' not found (Errcode: 13)
140116 15:59:22 [ERROR] Aborting
140116 15:59:22 [Note] /usr/libexec/mysqld: Shutdown complete
140116 15:59:22 mysqld ended
或者
140116 16:17:06 mysqld started
140116 16:17:06 [Warning] option 'max_join_size': unsigned value 18446744073709551615 adjusted to 4294967295
140116 16:17:06 [Warning] option 'max_join_size': unsigned value 18446744073709551615 adjusted to 4294967295
/usr/libexec/mysqld: File '/home/log-bin.index' not found (Errcode: 13)
140116 16:17:06 [ERROR] Aborting
140116 16:17:06 [Note] /usr/libexec/mysqld: Shutdown complete
140116 16:17:06 mysqld ended
这种报错有可能是设置bin-log日志路径时,没有指定在Mysql所属用户的目录下。
也有另外一种可能是:

mysql> select @@max_join_size;
+-----------------+
| @@max_join_size |
+-----------------+
| 705032704 |
+-----------------+
1 row in set (0.00 sec)
mysql> SET sql_max_join_size=4294967295;
Query OK, 0 rows affected (0.00 sec)

设置了max_join_size参数,当然,一般来说这个参数的默本回答被提问者和网友采纳

mysql 简单主从

主服务器master

[[email protected] ~]# vim /etc/my.cnf
[mysqld]
log-bin=mysql-bin   #必须开启log-bin
server-id=129       #服务器ID

从服务器slave

[[email protected] ~]# vim /etc/my.cnf
[mysqld]
log-bin=mysql-bin   #开启log-bin(可选)
server-id=129       #服务器ID
[root@localhost ~]# systemctl restart mysqld  #主从服务器

 

mysql> GRANT REPLICATION SLAVE ON *.* to ‘mysync‘@‘%‘ identified by ‘123456‘;  #主服务器授权账号
mysql> show master status;
+------------------+----------+--------------+------------------+-------------------+
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+-------------------+
| mysql-bin.000001 |      439 |              |                  |                   |
+------------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)

#查看master状态
mysql> stop slave;
mysql>change master to master_host=‘192.168.100.129‘,master_user=‘mysync‘,master_password=‘123456‘, master_log_file=‘mysql-bin.000004‘,master_log_pos=308;
mysql> stop slave;
mysql> show slave status\G  #查看slave状态
   Slave_IO_Running: Yes  #必须为Yes
   Slave_SQL_Running: Yes #必须为Yes

如果在master 也配置 slave 架构就成了主主模式 需要注意数据一致性的问题

虚拟机克隆需要重新生成auto.cnf

[root@localhost ~]# mv /var/lib/mysql/auto.cnf /tmp
[root@localhost ~]# systemctl restart mysqld

以上是关于mysql log-bin 默认是开启的吗的主要内容,如果未能解决你的问题,请参考以下文章

MySQL设置log-bin后服务器重启失败的解决办法

MySQL设置log-bin后服务器重启失败的解决办法

mysql日志全部都没有开启,怎么回事

mysql 主从备份

mysql 简单主从

[经验分享]MySQL8.0及以上版本 关闭log-bin 功能