This exercise comes in the chapter on quadratic residues and the Legendre symbol. I have absolutely no idea how to prove what it asks. None of the theorems in the chapter seem relevant.Prove that if $\displaystyle p$ is an odd prime then $\displaystyle x^2\equiv 2\mod p$ has solutions if and only if $\displaystyle p\equiv1$ or $\displaystyle 7\mod 8$.

My professor has been skipping around in the book, and blending in his own material. I suspect he may have skipped over something from an earlier chapter, which I need to solve this.

Hints or useful theorems would be much appreciated.