when any of you enters the mosque he should invoke blessing on the prophet ﷺ and then he should say: O Allah, open to me the gates of thy mercy. And when he goes out, he should say: O Allah, I ask thee out of Thine abundance. (Using translation from Abū Dāʾūd 465)
قَالَ رَسُولُ اللهِ ﷺ إِذَا دَخَلَ أَحَدُكُمُ الْمَسْجِدَ فَلْيُسَلِّمْ عَلَى النَّبِيِّ ﷺ ثُمَّ لِيَقُلِ اللهُمَّ افْتَحْ لِي أَبْوَابَ رَحْمَتِكَ وَإِذَا خَرَجَ فَلْيَقُلِ اللهُمَّ إِنِّي أَسْأَلُكَ مِنْ فَضْلِكَ