In general, these sentences do not read fluently. Instead of 'to database' I would say 'to the database' or 'to a database' (the former is used when you have already mentioned the existence of a database).
In the phrase 'it will take the photo' the word 'it' refers to the gate. Normally gates cannot take photos, but if the context has mentioned that the gate is some kind of automatic system then this is fine. Otherwise, I would recommend changing 'it' for something like 'the system' or similar so that a common gate is not taking photos.
You do not need to repeat the 'will' auxiliary when several actions will happen. In that sense, #2 is preferable to #3. #1 mixes future and present so it's undesirable.
Your best bet is then
2a. When you are approaching the gate, it will take the photo of you and compare that photo to the database.
Or you may want to simplify it further to
2b. When you approach the gate, it will take the photo of you and compare that photo to the database.
Here the meaning changed a little bit in that when saying 'approaching' the photo might be taken at a distance but in #2b you have to be near the gate for the photo to be taken, which I assume is your intent.
Or you may want to shorten it
2c. When you approach the gate, it will take your photo and compare the photo to the database.
2d. When you approach the gate, it will take your photo and compare it to the database.