Lord Krishna is one of the greatest devotees of Lord Shiva. In Mahabharata , Anushasana Parva, ie., In Book 13, Chapter 15 verses 1 to 51, Lord Krishna explains to Yudistira his association with Rishi Upamanyu. He also explains how he got initiated into Pashupata Diksha and how he obtained the grace of Lord Shiva.
Krishna recounts his fortunate meeting with Rishi Upamanyu. At that time, Upamanyu explains Krishna how he has got the divine grace of Lord Shiva. Inspired by the words of Upamanyu, krishna asks Upamanyu whether he could also obtain the grace of Lord Shiva. The story is continued as follows....
Maha Bharata Book 13, Chapter 15 verses 1 to 51
etān sahasraśaś cānyān samanudhyātavān haraḥ
kasmāt prasādaṃ bhagavān na kuryāt tava mādhava
tvādṛśena hi devānāṃ ślāghanīyaḥ samāgamaḥ
brahmaṇyenānṛśaṃsena śraddadhānena cāpy uta
japyaṃ ca te pradāsyāmi yena drakṣyasi śaṃkaram
"Upamanyu said, 'Without doubt, O thou of eyes like lotus-petals, thou wilt obtain a sight of Mahadeva very soon, even as, O sinless one, I succeeded in obtaining a sight of him. O thou of immeasurable prowess, I see with my spiritual eyes that thou wilt, in the sixth month from this, succeed in obtaining a sight of Mahadeva, O best of all persons. Thou, O foremost of the Yadus, wilt obtain from Maheswara and his spouse, four and twenty boons. I tell thee what is true. Through the grace of that Deity endued with supreme wisdom, the Past, the Future and the Present are known to me. The great Hara has favoured these Rishis numbering by thousands and others as numerous. Why will not the puissant Deity show favour to thee, O Mahadeva? The meeting of the gods is always commendable with one like thee, with one that is devoted to the Brahmanas, with one that is full of compassion and that is full of faith. I shall give thee certain Mantras. Recite them continuously. By this thou art certain to behold Sankara.'
abruvaṃ tam ahaṃ brahmaṃs tvatprasādān mahāmune
drakṣye ditijasaṃghānāṃ mardanaṃ tridaśeśvaram
"The blessed Vishnu continued, 'I then said unto him, O regenerate one, through thy grace, O great ascetic. I shall behold the lord of the deities, that grinder of multitudes of Diti's sons.
dine 'ṣṭame ca vipreṇa dīkṣito 'haṃ yathāvidhi
daṇḍī muṇḍī kuśī cīrī ghṛtākto mekhalī tathā
Eight days, O Bharata, passed there like an hour, all of us being thus occupied with talk on Mahadeva. On the eighth day, I underwent the Diksha (initiation) according to due rites, at the hands of that Brahmana and received the staff from his hands I underwent the prescribed shave. I took up a quantity of Kusa blades in my hand. I wore rags for my vestments. I rubbed my person with ghee. I encircled a cord of Munja grass round my loins
māsam ekaṃ phalāhāro dvitīyaṃ salilāśanaḥ
tṛtīyaṃ ca caturthaṃ ca pañcamaṃ cānilāśanaḥ
For one month I lived on fruits. The second month I subsisted upon water. The third, the fourth and the fifth months I passed, living upon air alone.
ekapādena tiṣṭhaṃś ca ūrdhvabāhur atandritaḥ
tejaḥ sūryasahasrasya apaśyaṃ divi bhārata
I stood all the while, supporting myself upon one foot and with my arms also raised upwards, and foregoing sleep all the while I then beheld, O Bharata, in the firmament an effulgence that seemed to be as dazzling as that of a thousand Suns combined together.
tasya madhyagataṃ cāpi tejasaḥ pāṇḍunandana
indrāyudhapinaddhāṅgaṃ vidyunmālā gavākṣakam
nīlaśailacaya prakhyaṃ balākā bhūṣitaṃ ghanam
Towards the centre of that effulgence, O son of Pandu, I saw a cloud looking like a mass of blue hills, adorned with rows of cranes, embellished with many a grand rainbow, with flashes of lightning and the thunder-fire looking like eyes set on it.
tam āsthitaś ca bhagavān devyā saha mahādyutiḥ
tapasā tejasā kāntyā dīptayā saha bhāryayā
Within that cloud was the puissant Mahadeva. himself of dazzling splendour, accompanied by his spouse Uma.Verily, the great Deity seemed to shine with his penances, energy, beauty, effulgence,and his dear spouse by his side.
rarāja bhagavāṃs tatra devyā saha maheśvaraḥ
somena sahitaḥ sūryo yathā meghasthitas tathā
The puissant Maheswara, with his spouse by his side, shone in the midst of that cloud. The appearance seemed to be like that of the Sun in the midst of racking clouds with the Moon by his side.
saṃhṛṣṭaromā kaunteya vismayotphullalocanaḥ
apaśyaṃ devasaṃghānāṃ gatim ārtiharaṃ haram
The hair on my body, O son of Kunti, stood on its end, and my eyes expanded with wonder upon beholding Hara, the refuge of all the deities and the dispeller of all their griefs.
kirīṭinaṃ gadinaṃ śūlapāṇiṃ; vyāghrājinaṃ jaṭilaṃ daṇḍapāṇim
pinākinaṃ vajriṇaṃ tīkṣṇadaṃṣṭraṃ; śubhāṅgadaṃ vyālayajñopavītam
Mahadeva was adorned with a diadem on his head. He was armed with his Sula. He was clad in a tiger-skin, had matted locks on his head, and bore the staff (of the Sanyasin) in one of his hands. He was armed, besides with his Pinaka and the thunderbolt. His teeth was sharp-pointed. He was decked with an excellent bracelet for the upper arm. His sacred thread was constituted by a snake
divyāṃ mālām urasāneka varṇāṃ; samudvahantaṃ gulpha deśāvalambām
candraṃ yathā pariviṣṭaṃ sasaṃdhyaṃ; varṣātyaye tadvad apaśyam enam
He wore an excellent garland of diversified colours on his bosom, that hung down to his toes. Verily, I beheld him like the exceedingly bright moon of an autumnal evening.
prathamānāṃ gaṇaiś caiva samantāt parivāritam
śaradīva suduṣprekṣyaṃ pariviṣṭaṃ divākaram
Surrounded by diverse clans of spirits and ghosts, he looked like the autumnal Sun difficult of being gazed at for its dazzling brightness
ekādaśa tathā cainaṃ rudrāṇāṃ vṛṣavāhanam
astuvan niyatātmānaḥ karmabhiḥ śubhakarmiṇam
Eleven hundred Rudras stood around that Deity of restrained soul and white deeds, then seated upon his bull. All of them were employed in hymning his praises.
ādityā vasavaḥ sādhyā viśve devās tathāśvinau
viśvābhiḥ stutibhir devaṃ viśvadevaṃ samastuvan
The Adityas, the Vasus, the Sadhyas, the Viswedevas, and the twin Aswins praised that Lord of the universe by uttering the hymns occurring in the scriptures.
śatakratuś ca bhagavān viṣṇuś cāditinandanau
brahmā rathantaraṃ sāma īrayanti bhavāntike
The puissant Indra and his brother Upendra, the two sons of Aditi, and the Grandsire Brahma, all uttered, in the presence of Bhava, the Rathantara Saman.
yogīśvarāḥ subahavo yogadaṃ pitaraṃ gurum
brahmarṣayaś ca sa sutās tathā devarṣayaś ca vai
Innumerable masters of Yoga, all the regenerate Rishis with their children, all the celestial Rishis,
pṛtivī cāntarikṣaṃ ca nakṣatrāṇi grahās tathā
māsārdha māsā ṛtavo rātryaḥ saṃvatsarāḥ kṣaṇāḥ
the goddess Earth, the Sky (between Earth and Heaven), the Constellations, the Planets, the Months, the Fortnights, the Seasons, Night, the Years, the Kshanas,
muhūrtāś ca nimeṣāś ca tathaiva yugaparyayāḥ
divyā rājan namasyanti vidyāḥ sarvā diśas tathā
the Muhurtas, the Nimeshas, the Yugas one after another, all the celestial Sciences and branches of knowledge, and all beings conversant with Truth, were seen bowing down unto that Supreme Preceptor, that great Father, that giver (or origin) of Yoga.
sanatkumāro vedāṃś ca itihāsās tathaiva ca
marīcir aṅgirā atriḥ pulastyaḥ pulahaḥ kratuḥ.
Sanatkumara, the Vedas, the Histories, Marichi, Angiras, Atri, Pulastya, Pulaha, Kratu,
manavaḥ sapta somaś ca atharvā sa bṛhaspatiḥ
bhṛgur dakṣaḥ kaśyapaś ca vasiṣṭhaḥ kāśya eva ca
the seven Manus, Soma, the Atharvans, and Vrihaspati, Bhrigu, Daksha, Kasyapa, Vasishtha, Kasya,
chandāṃsi dīkṣā yajñāś ca dakṣiṇāḥ pāvako haviḥ
yajñopagāni dravyāṇi mūrtimanti yudhiṣṭhira
the Schandas, Diksha, the Sacrifices, Dakshina, the Sacrificial Fires, the Havis (clarified butter) poured in sacrifices, and all the requisites of the sacrifices, were beheld by me, O Yudhishthira, standing there in their embodied forms.
prajānāṃ patayaḥ sarve saritaḥ pannagā nagāḥ
devānāṃ mātaraḥ sarvā devapatnyaḥ sa kanyakāḥ
All the guardians of the worlds, all the Rivers, all the snakes, the mountains, the celestial Mothers, all the spouses and daughters of the celestials,
sahasrāṇi munīnāṃ ca ayutāny arbudāni ca
namasyanti prabhuṃ śāntaṃ parvatāḥ sāgarā diśaḥ
thousands upon thousands and millions of ascetics, were seen to bow down to that puissant Lord who is the soul of tranquillity. The Mountains, the Oceans, and the Points of the compass also did the same,
gandharvāpsarasaś caiva gītavāditrakovidāḥ
divyatānena gāyantaḥ stuvanti bhavam adbhutam
vidyādharā dānavāś ca guhyakā rākṣasās tathā
the Gandharvas and the Apsaras highly skilled in music, in celestial strains, sang and hymned the praises of Bhava who is full of wonder.The Vidyadharas, the Danavas, the Guhyakas, the Rakshasas,
sarvāṇi caiva bhūtāni sthāvarāṇi carāṇi ca
namasyanti mahārāja vān manaḥ karmabhir vibhum
purastād viṣṭhitaḥ śarvo mamāsīt tridaśeśvaraḥ
and all created beings, mobile and immobile, adorned, in thought, word and deed, that puissant Lord.Before me, that Lord of all the gods viz., Sarva, appeared seated in all his glory.
purastād viṣṭhitaṃ dṛṣṭvā mameśānaṃ ca bhārata
sa prajāpatiśakrāntaṃ jagan mām abhyudaikṣata
Seeing that Isana had showed himself to me by being seated in glory before my eyes, the whole universe, with the Grandsire and Sakra, looked at me.
īkṣituṃ ca mahādevaṃ na me śaktir abhūt tadā
tato māma bravīd devaḥ paśya kṛṣṇa vadasva ca
I, however, had not the power to look at Mahadeva. The great Deity then addressed me saying, 'Behold, O Krishna, and speak to me.
śirasā vandite deve devī prītā umābhavat
tato 'ham astuvaṃ sthāṇuṃ stutaṃ brahmādibhiḥ suraiḥ
Thou hast adorned me hundreds and thousands of times. There is no one in the three worlds that is dearer to me than thou.' After I had bowed unto him, his spouse, viz., the goddess Uma, became gratified with me. I then addressed in these words the great God whose praises are hymned by all the deities with the Grandsire Brahma at their head.'
Lord Krishna's Prayer to lord Shiva
namo 'stu te śāśvatasarvayone; brahmādhipaṃ tvām ṛṣayo vadanti
tapaś ca sattvaṃ ca rajas; tamaś ca tvām eva satyaṃ ca vadanti santaḥ
The blessed Vishnu said, 'I saluted Mahadeva, saying,--Salutations to thee, O thou that art the eternal origin of all things. The Rishis say that thou art the Lord of the Vedas. The righteous say that thou art Penance, thou art Sattwa, thou art Rajas, thou art Tamas, and thou art Truth
tvaṃ vai brahmā ca rudraś ca varuṇo 'gnir manur bhavaḥ
dhātā tvaṣṭā vidhātā ca tvaṃ prabhuḥ sarvato mukhaḥ
Thou art Brahma, thou art Rudras, thou art Varuna, thou art Agni, thou art Manu, thou art Bhava, thou art Dhatri, thou art Tashtri, thou art Vidhatri, thou art the puissant Master of all things, and thou art everywhere.
tvatto jātāni bhūtāni sthāvarāṇi carāṇi ca
tvam ādiḥ sarvabhūtānāṃ saṃhāraś ca tvam eva hi
All beings, mobile and immobile, have sprung from thee. This triple world with all its mobile and immobile entities, has been created by thee.
ye cendriyārthāś ca manaś ca kṛtsnaṃ; ye vāyavaḥ sapta tathaiva cāgniḥ
ye vā divisthā devatāś cāpi puṃsāṃ; tasmāt paraṃ tvām ṛṣayo vadanti
The Rishis say that thou art superior to the senses, the mind, the vital breaths, the seven sacrificial fires, all others that have their refuge in the all-pervading Soul, and all the deities that are adored and worthy of adoration.
vedā yajñāś ca somaś ca dakṣiṇā pāvako haviḥ
yajñopagaṃ ca yat kiṃ cid bhagavāṃs tad asaṃśayam
Thou, O illustrious one, art the Vedas, the Sacrifices, Soma, Dakshina, Pavaka, Havi, and all other requisites of sacrifice.
iṣṭaṃ dattam adhītaṃ ca vratāni niyamāś ca ye
hrīḥ kīrtiḥ śrīr dyutis tuṣṭiḥ siddhiś caiva tvad arpaṇā
The merit obtained by sacrifices, gifts made to others, the study of the Vedas, vows, regulations in respect of restraint, Modesty, Fame, Prosperity, Splendour, Contentment, and Success, all exist for leading to thee.
kāmaḥ krodho bhayaṃ lobho madaḥ stambho 'tha matsaraḥ
ādhayo vyādhayaś caiva bhagavaṃs tanayās tava
Desire, Wrath, Fear, Cupidity, Pride, Stupefaction, and Malice, Pains and Diseases, are, O illustrious one, thy children.
kṛtir vikāraḥ pralayaḥ pradhānaṃ prabhavo 'vyayaḥ
manasaḥ praramā yoniḥ svabhāvaś cāpi śāśvataḥ
avyaktaḥ pāvana vibho sahasrāṃśo hiraṇmayaḥ
Thou art all acts that creatures do, thou art the joy and sorrow that flow from those acts, thou art the absence of joy and sorrow, thou art that Ignorance which is the indestructible seed of Desire, thou art the high origin of Mind, thou art Puissance, and thou art Eternity.Thou art the Unmanifest, thou art Pavana, thou art inconceivable, thou art the thousand-rayed Sun, thou art the effulgent Chit, thou art the first of all the topics, and thou art the refuge of life.
ādir guṇānāṃ sarveṣāṃ bhavān vai jīvanāśrayaḥ
mahān ātmā matir brahmā viśvaḥ śambhuḥ svayambhuvaḥ
buddhiḥ prajñopalabdhiś ca saṃvit khyātir dhṛtiḥ smṛtiḥ
paryāya vācakaiḥ śabdair mahān ātmā vibhāvyase
Thou art Trigunas, Thou art Mahat atma, Thou art Brahman, Thou art Universe, Thou art Sambhu, and Thou art Self-born and Thou art intellect,Thou art Prajna,Thou art sound(vedas),
tvāṃ buddhvā brāhmaṇo vidvān an pramohaṃ nigacchati
hṛdayaṃ sarvabhūtānāṃ kṣetrajñas tvam ṛṣiṣṭutaḥ
Verily, regarding thee as all this, the learned Brahmanas win over that ignorance which lies at the root of the world.Thou residest in the heart of all creatures, and thou art adored by the Rishis as Kshetrajna.
sarvataḥ pāṇipādas tvaṃ sarvato 'kṣiśiromukhaḥ
sarvataḥ śrutimāṁl loke sarvam āvṛtya tiṣṭhasi
Thy arms and feet extend to every place, and thy eyes, head, and face are everywhere. Thou hearest everywhere in the universe, and thou stayest, pervading all things.
phalaṃ tvam asi tigmāṃśo nimeṣādiṣu karmasu
tvaṃ vai prabhārciḥ puruṣaḥ sarvasya hṛdi saṃsthitaḥ
aṇimā laghimā prāptir īśāno jyotir avyayaḥ
Of all acts that are performed in the Nimeshas and other divisions of time that spring in consequence of the puissance of the Sun, thou art the fruit. Thou art the original effulgence (of the supreme Chit).Thou art Purusha, and thou residest in the hearts of all things. Thou art the various Yogic attributes of success, viz., Subtility and Grossness and Fruition and Supremacy and Effulgence and Immutability.
tvayi buddhir matir lokāḥ prapannāḥ saṃśritāś ca ye
dhyānino nityayogāś ca satyasaṃdhā jitendriyāḥ
Understanding and intelligence and all the worlds rest upon thee. They that are devoted to meditation, that are always engaged in Yoga, that are devoted to or firm in Truth and that have subjugated their passions, seek thee and rest on thee.
yas tvāṃ dhruvaṃ vedayate guhā śayaṃ; prabhuṃ purāṇaṃ puruṣaṃ viśvarūpam
hiraṇmayaṃ buddhimatāṃ parāṃ gatiṃ; sa buddhimān buddhim atītya tiṣṭhati
They that know thee for one that is Immutable, or one that resides in all hearts, or one that is endued with supreme puissance, or one that is the ancient Purusha, or one that is pure Knowledge, or one that is the effulgent Chit, or one that is the highest refuge of all persons endued with intelligence, are certainly persons of great intelligence. Verily, such persons stay, transcending intelligence.
viditvā sapta sūkṣmāṇi ṣaḍaṅgaṃ tvāṃ ca mūrtitaḥ
pradhānavidhiyogasthas tvām eva viśate budhaḥ
By understanding the seven subtile entities (viz., Mahat, Ego, and five subtile primal elements called Tanmatras), by comprehending thy six attributes (of Omniscience, Contentment of Fullness, Knowledge without beginning, Independence, Puissance that is not at fault at any time and that is infinite), and being conversant with Yoga that is freed from every false notion, the man of knowledge succeeds in entering into thy great self
vam ukte mayā pārtha bhave cārti vināśane
carācaraṃ jagat sarvaṃ siṃhanādam athākarot
After I had said these words, O Partha, unto Bhava, that dispeller of grief and pain, the universe, both mobile and immobile, sent up a leonine shout (expressive of their approval of the correctness of my words).
sa vipra saṃghāś ca surāsurāś ca; nāgāḥ piśācāḥ pitaro vayāṃsi
rakṣogaṇā būta gaṇāś ca sarve; maharṣayaś caiva tathā praṇemuḥ
The innumerable Brahmanas there present, the deities and the Asuras, the Nagas, the Pisachas, the Pitris, the birds, diverse Rakshasas, diverse classes of ghosts and spirits, and all the great Rishis, then bowed down unto that great Deity.
mama mūrdhni ca divyānāṃ kusumānāṃ sugandinām
rāśayo nipatanti sma vāyuś ca susukho vavau
There then fell upon my head showers of celestial flowers possessed of great fragrance, and delicious winds blew on the spot.
nirīkṣya bhagavān devīm umāṃ māṃ ca jagad dhitaḥ
śatakratuṃ cābhivīkṣya svayaṃ mām āha śaṃkaraḥ
The puissant Sankara then, devoted to the good of the universe, looked at the goddess Uma and the lord of the celestials and myself also, and thus spoke unto me,
vidmaḥ kṛṣṇa parāṃ bhaktim asmāsu tava śatruhan
kriyatām ātmanaḥ śreyaḥ prītir hi paramā tvayi
vṛṇīṣvāṣṭau varān kṛṣṇa dātāsmi tava sattama
brūhi yādava śārdūlayān icchasi sudurlabhān
-We know, O Krishna, that thou, O slayer of foes, art filled with the greatest devotion towards us. Do what is for thy good. My love and affection for thee is very great. Do thou ask for eight boons. I shall verily give them unto thee, O Krishna, O best of all persons, tell me what they are, O chief of the Yadavas. Name what thou wishest. However difficult of attainment they be, thou shalt have them still.'"