The Gibbs free energy is defined as
$$ G = U-TS+pV$$
It is also known that the chemical potential is the per-particle Gibbs free energy so:
$$ G=\mu N $$
Now, putting the two together we get
$$ U = TS - pV + \mu N$$
I can also take the differential of the above:
$$ dU= d(TS) - d(pV) + d(\mu N) $$
Expanding the products and rearranging terms:
$$ dU = TdS-pdV + \mu dN + S dT - Vdp + N d\mu$$
This, however, seems at odds with the second law of thermodynamics which should write as
$$ dU=TdS-pdV+\mu dN $$
My question is, how do I resolve this contradiction? From here I would conclude that
$$ SdT - Vdp + N d\mu =0 $$
Is this true? If so, how do I prove it? If not, where does the contradiction come from?