Buraida said that God's messenger used to teach them to say when they went out to the cemeteries, “Peace be upon you, inhabitants of the dwellings who are of the number of the believers and the Muslims. If God will, we shall join you. We ask God to grant us and you wellbeing.”
Abu Huraira said that the Prophet visited his mother’s grave and wept and caused those around him to weep. He then said, "I asked my Lord's permission to pray for forgiveness for her, but I was not allowed; I then asked His permission to visit her grave and I was allowed; so visit graves, for they make one mindful of death.”
Ibn 'Abbas said that when God's messenger passed by some graves in Medina he turned his face towards them and said, “Peace be upon you, inhabitants of the graves. God forgive us and you. You have gone before us and we are coming after.”
Tirmidhi transmitted it saying this is a hasan gharib tradition.
Buraida reported God's messenger as saying, “I forbade you to visit graves, but you may now visit them; I forbade you to eat the flesh of sacrificial animals after three days, but you may now keep it as long as you feel inclined; and I forbade you nabidh except in a water-skin, so you may drink it from all kinds of water-skins, but you must not drink anything intoxicating.”