Grainger, 32, has spent the past five years with Carlisle and previously played in Scotland for Brechin City, Dundee United, St Johnstone, Hearts and St Mirren.
He will take charge of the relegated club in July and has agreed a one-year contract with the option of a further 12 months.
The left-back will also register as a player.
Keep up-to-date with our exclusive email newsletters.
Subscribe