How To Enable/Change MySQL general_log_file location.

  • 1- Make a full backup of your database
  • 2- Shutdown your mysql server.
  • [root@xxxx2 mysql]# /etc/init.d/mysqld stop
    Stopping mysqld:                                           [  OK  ]
  • 3- Create/Choose the new location where the file will be written and make sure is owned by the mysql user and mysql group. In our case the new location will be "/mysql_log"
  • 4- Edit you my.cnf file and add to [mysqld] the new "log_slow_queries" path value.
  •  general_log_file=/mysql_log/xxxx2_general_log_file.log
  • 5- Relocate general_log_file.log file to the new locations keeping the original file permissions. This only if the general_log_file.log was enabeled already. If it does not exixsts then create it before you start the server.
  • [root@xxxx2 ]# cp mysql-bin.* /mysql_log/xxxx2_general_log_file.log
     or
    [root@xxxx2 ]# touch /mysql_log/xxxx2_general_log_file.log
    [root@xxxx2 ]# chown mysql:mysql xxxx2_general_log_file.log
  • 6- Start your server now and enable the .
  • [root@xxxx2 mysql_dados]# /etc/init.d/mysqld start
    Starting mysqld:                                           [  OK  ]
    
    
    [root@xxxx2 mysql_log]# mysql -uroot -p
    Enter password:
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 3
    Server version: 5.1.69-log Source distribution
    
    mysql> SET GLOBAL general_log = 'ON';
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> show variables like '%general%';
    +------------------+----------------------------------------+
    | Variable_name    | Value                                  |
    +------------------+----------------------------------------+
    | general_log      | ON                                     |
    | general_log_file | /mysql_log/xxxx2_general_log_file.log |
    +------------------+----------------------------------------+
    2 rows in set (0.00 sec)