If p=2 we have the solution x=1, for any odd prime we can write Wilson's theorem in the form
product of all j's from 1 to (p-1)/2 j(p-j) is congruent to -1(mod p) but j(p-j) is congruent to (-j)^{2}(mod p) and we get (-1)^{(p-1)/2}product of all j's from 1 to (p-1)/2 j^{2} is congruent to -1(mod p)
hence for p congruent 1(mod 4) we get a solution of x^{2} is congruent to (-1)(mod p) suppose p=-2 or, p not congruent to 1(mod 4) then p is congruent to 3(mod 4)
In this case, if for some integer r, we have r^{2} is congruent to -1(mod p) then (x^{2})^(p-1)/2 is congruent to (-1)^(p-1)/2(mod p)
hence x^(p-1) is congruent to -1(mod p) since (p,x) =1
we get p/2, a contradiction.