Mysql – Can’t set log_bin_trust_function_creators=1 on machine startup – MySQL 8.0

mysql-8.0Ubuntu

I'm trying to put the log_bin_trust_function_creators=1 parameter into the my.cnf configuration file to set the variable correctly on startup on a machine with Ubuntu 20.04 LTS. But every time I save the file with this line written in the config file, when I try to access the db I can't log in and iIhave this error output message:

mysql: [ERROR] Found option without preceding group in config file /etc/mysql/my.cnf at line 23.
mysql: [ERROR] Fatal error in defaults handling. Program aborted!

When I use SET GLOBAL log_bin_trust_function_creators=1; the parameter and the db work fine, but I would prefer to not having to reboot the machine when I set this parameter.

The version that we're using is mysql Ver 8.0.20-0ubuntu0.20.04.1 for Linux on x86_64 ((Ubuntu))

Can someone help me with this problem?

Best Answer

Put it under mysqld, there it should be found and set

[mysqld]
log-bin-trust-function-creators = 1