I found the problem. There was a UNIX socket problem. The root user can connect to the DB via localhost but cannot connect from 127.0.0.1. It also tries to connect from 127.0.0.1 in Cron.
I solved the problem by connecting to the DB as root and running the following command.
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'MY_ROOT_PASSWORD';
CREATE USER 'root'@'127.0.0.1' IDENTIFIED BY 'MY_ROOT_PASSWORD';
GRANT ALL PRIVILEGES ON . TO 'root'@'127.0.0.1' WITH GRANT OPTION;
FLUSH PRIVILEGES;
In addition, while sites used to be able to connect to the db with both internal IP (127.0.0.1) and localhost, after your last update they can only connect with internal IP. Root is only with localhost. This may be due to your mysql user authorization changes in the last update.
If those who experience the same error run the above code on their databases by writing their root password to the MY_ROOT_PASSWORD section, the problem will be solved.