Sahih Muslim Book 6, Hadith 83
A hadith like this has been narrated from the Messenger of Allah (ﷺ) by Abu Usaid.
When any one of you enters the mosque, he should say:" O Allah! open for me the doors of Thy mercy" ; and when he steps out he should say: 'O Allah! I beg of Thee Thy Grace." (Imam Muslim said: I heard Yahya saying: I transcribed this hadith from the compilation of Sulaiman b. Bilal.)
When any one of you enters the mosque, he should observe two rak'ahs (of Nafl prayer) before sitting.