medina justifiably fearing for his safety , muhammad then , in the year 622 , immigrated to yathrib , and not long thereafter the name of the city was changed to medina , meaning city of the prophet .