كتاب المقدمة
The Book of the Sunnah
(17)
Chapter: The virtue of the scholars, and encouragement to seek knowledge
(17)
باب فَضْلِ الْعُلَمَاءِ وَالْحَثِّ عَلَى طَلَبِ الْعِلْمِ
Sunan Ibn Majah 224
It was narrated from Anas bin Malik that the Messenger of Allah (ﷺ) said:
"Seeking knowledge is a duty upon every Muslim, and he who imparts knowledge to those who do not deserve it, is like one who puts a necklace of jewels, pearls and gold around the neck of swines."

Note:
"Seeking knowledge is a duty upon every Muslim" is authentic through many sources, but the remaining text is not acceptable.
حَدَّثَنَا هِشَامُ بْنُ عَمَّارٍ، حَدَّثَنَا حَفْصُ بْنُ سُلَيْمَانَ، حَدَّثَنَا كَثِيرُ بْنُ شِنْظِيرٍ، عَنْ مُحَمَّدِ بْنِ سِيرِينَ، عَنْ أَنَسِ بْنِ مَالِكٍ، قَالَ قَالَ رَسُولُ اللَّهِ ـ صلى الله عليه وسلم ـ ‏ "‏ طَلَبُ الْعِلْمِ فَرِيضَةٌ عَلَى كُلِّ مُسْلِمٍ وَوَاضِعُ الْعِلْمِ عِنْدَ غَيْرِ أَهْلِهِ كَمُقَلِّدِ الْخَنَازِيرِ الْجَوْهَرَ وَاللُّؤْلُؤَ وَالذَّهَبَ ‏"‏ ‏.‏
Grade: Chain is Da'if Jaddan (very weak) (Darussalam)
Reference : Sunan Ibn Majah 224
In-book reference : Introduction, Hadith 0
English translation : Vol. 1, Book 1, Hadith 224