How does $x^2-8x+17=0$ have nonreal solutions? 
The solutions of $x^2-8x+17=0$ are $4 + i$ and $4 - i$.

Well, I calculated and the results are different.
$$\begin{align}
x^2-8x+17 &= 0 \\
x^2-8x &=17 \\
x(x-8) &= 17 
\end{align}$$
So the roots are $x=17$ or $x=17+8=25$.
Why $i$ comes from the problem? Could you please explain about it?

Firstly, your rearrangement should have given $x(x-8)=-17$. Secondly, $x(x-8)=c\implies x=c\lor x-8=c$ only works for $c=0$, because non-zero $c$ have other factorizations. The correct observation is that $(x-4)^2=x^2-8x+16=-1=i^2$, so $x-4=\pm i$.
