Gandalf, true to his role as a skilled advisor of all the free peoples of Middle-earth, knows many languages of Elvish and Mannish origins, at least a bit of Khuzdul too. Did Tolkien ever reveal the complete extent of Gandalf's linguistic knowledge?
As the Fellowship were waiting outside the Doors of Durin to enter Moria, Gandalf remarked as he was searching for the opening words
I once knew every spell in all the tongues of Elves or Men or Orcs, that was ever used for such a purpose.
He went on to say that he could remember "ten score" of such spells without any effort. This, coupled with Gandalf's well-known nature as a traveller (one of his nicknames was the Grey Pilgrim) indicated that he would have ecountered many peoples and gained knowledge of a wide variety of languages during his two thousand or so years in Middle-earth, though as far as I know Tolkien never placed a finite number on the total of Gandalf's linguistic skills.
"All the tongues" would suggest a knowledge of Quenya, Sindarin (Elvish), Adunaic (spoken by Men from Numenor), Westron (the common tongue) as well as the languages spoken by the Northmen and their descendants (such as the Rohirrim and the Men of Dale), as well as Black Speech (which he spoke aloud in Rivendell) and other languages used by the Orc-folk. This may also extended to languages used by the Corsairs of Umbar and even the Haradrim and the Men of Rhun.
One language that he may not have had a great deal of knowledge of is Khuzdul, the language of the Dwarves. Just before he attempted to discover the password for the doors, he remarks hopefully that
Only a few trials, I think, will be needed; and I shall not have to call on Gimli for words of the secret dwarf-tongue that they teach to none.
(from The Fellowship of the Ring, chapter 4 (A Journey in the Dark))