Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I need to select the OS user during trigger execution to insert into a table. How can I select the OS User as it may be different from the MySQL user?

share|improve this question
1  
What language is the client code for starters? On what OS? –  gbn Feb 21 '13 at 15:03
    
We are on a UNIX box. The trigger is an on update trigger in MySQL. Basically, when a specific item is updated in this table, insert a row into a change history table. My requirement is to insert the UNIX user id as the updating user. –  user20435 Feb 21 '13 at 15:16

1 Answer 1

Some RDBMS (SQL Server) allow you to get this information easily. Especially for a direct DB connection from code running in the user's session on Windows, using Windows Auth to connect to SQL Server.

It can be done if the user connects to a website, which then connects to SQL Server too.

However, you're on MySQL.

Your simplest option is to have the client code send it in, derived from the OS. Ypu can then pass this in to the trigger as per this SO answer http://stackoverflow.com/questions/324605/mysql-trigger-storing-a-select-in-a-variable

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.