LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   how to enable binary logs in mysql (https://www.linuxquestions.org/questions/linux-server-73/how-to-enable-binary-logs-in-mysql-902011/)

kevmcool 09-08-2011 02:43 PM

how to enable binary logs in mysql
 
CentOS 5.6, MySQL 5.1.52

Test VM with fresh install of MySQL
SElinux permissive
yum groupinstall "MySQL Database"
All I did was start the server and set the root password for mysql
Now I am following How To Set Up Database Replication In MySQL and all is fine until I look for the .bin files and there are none there in:
/var/lib/mysql/
The user mysql has read and write on the data directory
mysql> SHOW BINARY LOGS;
ERROR 1381 (HY000): You are not using binary logging

So my question is:
Is binary logging enabled as default?
How do I enable binary logging?

I have been googling this for hours and no luck
Thanks in advance

zackwasa 09-08-2011 04:17 PM

Hi,

You need to add this to /etc/my.cnf:
Code:

log-bin=mysql-bin
The logs will go to the mysql data directory and will have the mysql-bin prefix

RMI

kevmcool 09-09-2011 02:48 AM

Should the binary logs be created on a restart?

[root@rhel6 ~]# cat /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

# Setup for DB replication
log-bin=mysql-bin

[root@rhel6 ~]# /etc/init.d/mysqld restart --log-bin
Stopping mysqld: [ OK ]
Starting mysqld: [ OK ]
[root@rhel6 ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.52 Source distribution

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show binary logs;
ERROR 1381 (HY000): You are not using binary logging
[root@rhel6 ~]# updatedb
[root@rhel6 ~]# locate mysql-bin

Thanks

kevmcool 09-09-2011 04:38 AM

The problem was that log-bin=mysql-bin was added to [mysqld_safe] and not [mysqld]

Thanks


All times are GMT -5. The time now is 11:07 PM.