# MySql log not created



## lucas1 (Aug 25, 2021)

Good afternoon. 

Today I noticed that there is no log mysql.
Did the following:

```
[mysqld]
log=/var/log/mysql.log
```


```
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?


----------



## lucas1 (Aug 25, 2021)

changed to for permissions:

```
log=/var/db/mysql/mysqld.log
```
still doesn't work logging.


----------



## covacat (Aug 25, 2021)

try log-error=


----------



## VladiBG (Aug 25, 2021)

There's no such variable "log=" for mysql 5.7.
Read https://dev.mysql.com/doc/refman/5.7/en/server-logs.html


----------



## lucas1 (Aug 25, 2021)

covacat said:


> try log-error=


Yes, worked.

But as enabled log every SQL query to databases?

```
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?


----------



## covacat (Aug 25, 2021)

for that is general-log


----------



## SirDice (Aug 25, 2021)

lucas1 said:


> But as enabled log every SQL query to databases?








						MySQL :: MySQL 5.7 Reference Manual :: 5.4.3 The General Query Log
					






					dev.mysql.com


----------



## dbdemon (Aug 25, 2021)

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).


----------



## lucas1 (Aug 25, 2021)

SirDice said:


> MySQL :: MySQL 5.7 Reference Manual :: 5.4.3 The General Query Log
> 
> 
> 
> ...


log-output=FILE

general_log file filling up now.

but how does it reflect the unsuccessful DML requests?


----------



## Alain De Vos (Aug 25, 2021)

Note. You only use logfiles to find or solve problems. Because there is a huge performance hit.


----------



## astyle (Aug 25, 2021)

lucas1 said:


> /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.


----------



## lucas1 (Aug 26, 2021)

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.


----------



## VladiBG (Aug 26, 2021)

Read my first post again.
Use audit log events.


----------



## dbdemon (Aug 26, 2021)

VladiBG said:


> 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 ...?


lucas1 said:


> 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 ...)


----------



## VladiBG (Aug 26, 2021)

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``


----------



## astyle (Aug 26, 2021)

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.


----------

