0

I know it's weird to ask this question, but I'm looking for a way to get the OS USER in MySQL; not the schema user or the device name.

For instance; in oracle, you can get the OS USER using:

SELECT SYS_CONTEXT('USERENV', 'OS_USER') FROM DUAL;
-- it returns n.awad for example

In MYSQL I found these statements, but none of them returns the required value:

SELECT USER(); 
-- it returns schemaUser@deviceName
SELECT CURRENT_USER();
-- it returns schemaUser@%
SELECT HOST FROM INFORMATION_SCHEMA.PROCESSLIST WHERE State ='executing';
-- it returns deviceName:port

So, is there any function that returns the required value?

Nimer Awad
  • 3,967
  • 3
  • 17
  • 31
  • Are you aware that this information is provided by the client application in Oracle and can not be relied upon? –  Feb 01 '21 at 13:23
  • @a_horse_with_no_name really? but I used it in a trigger and I got the required information. – Nimer Awad Feb 01 '21 at 13:26
  • 1
    You can't rely on that information - especially not for security reasons. The JDBC or ODBC driver and the Oracle client stuff simply provide a default value for the OS user but nothing prevents the application using those client software to provide a different name (the same is true fot application name as well). So if you rely on that in your trigger for security reasons, you don't have any security at all –  Feb 01 '21 at 13:31

0 Answers0