In the noble family of the Rimsky-Korsakovs, naval service was a tradition – the boy’s great-grandfather was a rear admiral under Empress Elizabeth Petrovna, his uncle was a rear admiral, and later his older brother became one as well. And little Nika, who aspired to emulate him, entered the Naval Cadet Corps in St. Petersburg in 1956 at the age of 12 (https://reveal.world/story/morskoj-kadetskij-korpus). He studied with pleasure, easily, and tried to have grades no lower than 10 points (maximum 12 points). From a letter by the 14-year-old cadet: “Tomorrow we have firing practice again, we will be securing the topsail, lowering the topgallant yards; but these exercises are very fun, although you get terribly tired; pulling the lower edge of the sail to the yard, you get completely soaked…”
On weekends and holidays, he tried to get to the theater. The opera by Glinka “A Life for the Tsar” (“Ivan Susanin”) made a huge impression on him. He recalled: “I already knew quite a lot of good music, but my greatest sympathy was for Glinka.” From 1860, Rimsky-Korsakov began to seriously engage in music. He started taking piano lessons, found the score of “Ruslan and Lyudmila,” and arranged it for piano four hands. In November 1861, Rimsky-Korsakov met the young but already well-known musician Balakirev in St. Petersburg. He not only highly appreciated the young man’s first musical attempts but also offered to be his mentor. Rimsky-Korsakov spent all his free evenings at Balakirev’s. There he met Cui, Mussorgsky, Stasov, Borodin, who later formed the group known as “The Mighty Handful.” This acquaintance was of great importance for the further development of the future composer’s talent.
In 1862, Rimsky-Korsakov graduated with honors from the Naval Cadet Corps. Academically, he ranked sixth in his class, so he was accepted as a midshipman on the military sailing ship “Almaz.” In April 1862, after graduating, midshipman Rimsky-Korsakov set off on a circumnavigation. Over three years, he visited many ports in Europe, North and South America, and in 1864 he was promoted to warrant officer. In May 1865, the clipper “Almaz” returned to Russia, and in July, “for excellent and diligent service,” warrant officer Rimsky-Korsakov was commended by order of the head of the Naval Ministry. But wherever he was, he always found time for his favorite pursuit – music. Even at the Naval Cadet Corps, Rimsky-Korsakov began working on his First Symphony, and upon returning from the voyage, he presented it to Balakirev. In 1865, the First Symphony was performed in the Duma hall at one of the concerts of the Free Music School and was very successful.
Sources:
http://vvkadet.shpl.ru/razdel2_5.html
https://www.prlib.ru/news/1291818