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. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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

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

share|improve this answer

Your Answer


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.