Matsya Purana (Jyotisha Selections) · by Vyasa
Chapter 2 · Graha Shanti
ग्रहशान्तिः
भास्करस्येश्वरं विद्यादुमाञ्च शशिनस्तथा ।स्कन्दमङ्गारकस्यापि बुधस्य च तथा हरिम् ॥ १३ ॥
In the full Matsya Purana this is print ch 92 (standard ch 93), verse 13.
Know Ishvara (Shiva) as the god of the Sun, and Uma as the goddess of the Moon. Know Skanda as the god of Mars, and Hari (Vishnu) as the god of Mercury.
Simple meaning: Shiva goes with the Sun, Uma with the Moon, Skanda with Mars and Vishnu with Mercury.
ब्रह्माणञ्च गुरोर्विद्याच्छुक्रस्यापि शचीपतिम् ।
Brahma goes with Jupiter, Indra with Venus, Yama with Saturn and Kala with Rahu.
केतोर्वै चित्रगुप्तञ्च सर्वेषामधिदेवताः ।
Chitragupta goes with Ketu. Agni, the waters, earth, Vishnu, Indra and Indrani begin the second set of gods.
प्रजापतिश्च सर्पाश्च ब्रह्मा प्रत्यधिदेवताः ।
Prajapati, the snakes and Brahma complete the second set. Vinayaka, Durga, Vayu, Akasha and the two Ashvins are also called.