Way to check where the MySQL connection was initialized? Is there a way to identify who created the MySQL connection?

For example:
in file a.php
$conn = mysqli_connect($dbhost, $dbuser, $dbpwd, null, $port, $socket);
I would like to know that this connection was initialized from a.php

I switched on the logger but all it told me that the connection was made but not who initialized it.
Connect    root@localhost on  using Socket
Who has the root password?  If there are multiple admins with root permissions, change them to non "root" user names, but with ALL PRIVILEGES.  Then you can distinguish them in the general log.

"Socket" implies the same machine; nothing provides what program.

I recommend you add comments to every query, perhaps with the filename and line number (__LINE__).