MySql log not created

Good afternoon.

Today I noticed that there is no log mysql.
Did the following:
Code:
[mysqld]
log=/var/log/mysql.log

Code:
touch /var/log/mysql.log
chown mysql:mysql /var/log/mysql.log

/usr/local/etc/rc.d/mysql-server restart

service mysql-server status
mysql is not running.


mysql --version
mysql  Ver 14.14 Distrib 5.7.33, for FreeBSD12.2 (amd64)
MySql just doesn't start without any warnings.

how to fix and enable logging mysql.log?
 
try log-error=
Yes, worked.

But as enabled log every SQL query to databases?
Code:
 show variables like "general_log%";
+------------------+-------------------------+
| Variable_name    | Value                   |
+------------------+-------------------------+
| general_log      | ON                      |
| general_log_file | /var/db/mysql/mysql.log |
+------------------+-------------------------+
2 rows in set (0.00 sec)
But the file is not filling up SQL query.

or is it not here?
 
To be clear, general-log-file and log-error should point to different files.

To log every query, you can alternatively use slow_query_log=ON, slow_query_log_file=/path/to/file.log and long_query_time=0 (or some other value - the unit is seconds - if you only want to log queries that take at least x seconds).
 
/usr/local/etc/rc.d/mysql-server restart
Usually, the error output will also suggest to use onestart as opposed to start. Also, double-check the listings of your /usr/local/etc/rc.d/ directory - sometimes the correct command is actually /usr/local/etc/rc.d/mysqld onerestart.

Sometimes, it also helps to have the following line in /etc/rc.conf: mysqld_enable="YES".

Make sure to actually study the documentation for your copy of the databases/mysql57-server! Everything I'm suggesting - that's merely stuff typically found in the documentation.

FWIW, I'd actually suggest a fresh install of databases/mysql57-server - it's at version 5.7.35 these days, 5.7.33 and a bit earlier - they were problematic.
 
This is an example of a successful request:
begin
2021-08-26T04:08:35.133737Z 3 Query insert into history (itemid,clock,ns,value) values (23255,1629950915,105838982,0)
2021-08-26T04:08:35.134024Z 3 Query commit

And general_log all contains only successful requests
But how to find the unsuccessful request.
They should be.
Because there is a problem base MySQL.
 
Use audit log events.
Are you suggesting to use the MySQL Enterprise Audit log? I could be wrong, but I believe that is an enterprise-only feature, and I'm not sure there are MySQL Enterprise releases for FreeBSD ...?
And general_log all contains only successful requests
But how to find the unsuccessful request.
They should be.
Because there is a problem base MySQL.
Are you asking where to find a log of SQL statements that weren't executed because of syntax errors etc? I'm not really sure if there are any options for that on MySQL Community Edition.

(MariaDB has an SQL Error Log plugin if switching to MariaDB is an option ...)
 
Yes it's available for MySQL Enterprise as plugin. You can also use percona57 which has the plugin under /usr/local/lib/mysql/plugins/audit_log.so as alternative. Other method to debug those failed queries is to install a MySQL proxy sitting in front of your server so you can analyze all queries there.
During the development of the software is much easy to track those error status codes directly in MySQL Workbench. It will be like select * from sys.`statements_with_errors_or_warnings`
 
Packaged (pre-compiled) version of MySQL is usually compiled with very conservative options. I compile with as many options enabled as I can, from ports.
 
Back
Top