We never learn Melody was raised under that name; only:
[River:] It’s your daughter’s name in the language of the forest. Except they don’t have a word for "pond" because the only water in the forest is the river. The Doctor will find your daughter, and he will care for her, whatever it takes. And I know that. It’s me. I’m Melody. I’m your daughter.
Note that she never actually says that Melody was raised there; only that that's how the name was derived. From that, River knows Melody's name from River's past; whereas Melody doesn't learn who River is until Let's Kill Hitler.
The following is from Let's Kill Hitler:
Furthermore, given that Amy names her daughter Melody after her own daughter, and that Melody only takes the name River Song after learning it from the Doctor and her parents, the true origin of both names is somewhat problematic (especially as to why exactly the universe decided she needed two names); then again, ontological paradoxes are nothing new to Doctor Who.