Sunan Abi Da’ud – Hadith No : 465

Abu Usaid al-Ansari reported the Messenger of Allah (May peace be upon him) as saying: 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.

Hadith In Arabic Text :

حدثنا محمد بن عثمان الدمشقي، حدثنا عبد العزيز، – يعني الدراوردي – عن ربيعة بن أبي عبد الرحمن، عن عبد الملك بن سعيد بن سويد، قال سمعت أبا حميد، أو أبا أسيد الأنصاري يقول قال رسول الله صلى الله عليه وسلم ‏”‏ إذا دخل أحدكم المسجد فليسلم على النبي صلى الله عليه وسلم ثم ليقل اللهم افتح لي أبواب رحمتك فإذا خرج فليقل اللهم إني أسألك من فضلك ‏”‏ ‏.‏

Chapter : Prayer (Kitab Al-Salat) – كتاب الصلاة