Reputation: 1167
I want MySQL to create a new general log file and log everything to it.
When I type this into MySQL:
set global general_log_file='~/path/to/new/file';
and the file is one that I want MySQL to create upon handling some transactions after I've set the global variable (i.e. it doesn't exist yet), it gives me an error:
Variable 'general_log_file' can't be set to the value of '~/path/to/new/file'
However, if I do it with a filepath that looks like:
set global general_log_file='new/file';
it doesn't complain and assigns the variable accordingly, even though this new file doesn't exist yet either.
What's going on here?
Upvotes: 3
Views: 11565
Reputation: 11
SET GLOBAL general_log = 'ON';
SET GLOBAL general_log_file='/var/log/general_log/general.log';
If error occurs MySQL: Variable 'general_log_file' can't be set to the value of '/var/log/general_log/general.log'
Just simple change file owner to mysql
Example chown -p mysql:mysql /var/log/general_log
Then change file permission
Format: chown 777 <log_output_file_name>
Ex: chmod 777 general.log
After that execute,
SET GLOBAL general_log_file='/var/log/general_log/general.log';
Verify the result: show global variables like '%general_log_file%';
Output:
MariaDB [(none)]> show global variables like '%general_log_file%';
+------------------+----------------------------------+
| Variable_name | Value |
+------------------+----------------------------------+
| general_log_file | /var/log/general_log/general.log |
+------------------+----------------------------------+
1 row in set (0.00 sec)
Upvotes: 1
Reputation: 1517
change my cnf.ini
general_log_file = /var/log/mysql/new_file.log
general_log = 1
Then restart the mysql process
Server restarts and log flushing do not cause a new general query log file to be generated (although flushing closes and reopens it)
shell> mysqladmin flush-logs
Upvotes: 1