Show all the harmonic functions over $\mathbb{R}^N\setminus\{0\}$ such that $u(x)=f(|x|)$. This is an exercise of my course of PDE:

Show all the harmonic functions over $\mathbb{R}^N\setminus\{0\}$ such that $u(x)=f(|x|)$.

My Attempt
A function $g$ is called harmonic if $\Delta g=\sum_{i=1}^N\frac{\partial^2g}{\partial x_i^2}=0$. Let $r(x)=|x|$. We have that $u(x)=(f\circ r)(x)$. So
    $$
 \frac{\partial(f\circ r)(x)}{\partial x}=\frac{\partial f(r(x))}{\partial r(x)}\frac{\partial r(x)}{\partial x}=\pm \frac{\partial f(r(x))}{\partial r(x)}
 $$
    and
    $$
 \frac{\partial f(r(x))}{\partial r(x)}=f'(x)
 $$
    So,
    $$
 \frac{\partial^2(f\circ r)}{\partial x^2}=\pm f''(x)\geq 0
 $$
    As $u(x)=f(|x|)=(f\circ r)(x)$, we give that $u(x)$ is harmonic if
    $$
 \frac{\partial^2 u(x)}{\partial x_i^2}=0, \forall i\in {1,...,N}
 $$
I`m insecurity with this soluction.
 A: A couple of things here went wrong, firstly the $x_i$ derivative of $|x|=\sqrt{x_1^2+...+x_n^2}$ is $\frac{x_i}{\sqrt{x_1^2+...+x_n^2}}=\frac{x_i}{r}$.
And we seek $f(r)=g(x)$
And the $r$ derivative of $f$ is $f'(r)$ not $f'(x)$. 
Then we carefully calculate that the second $x_i$ derivative of $f$ to be $f''(r)\frac{x_i^2}{r^2}+f'(r)(\frac{1}{r}-\frac{x_i^2}{r^3})$
This should put you on better footing.
In conclusion sum what we have found to get:
$-\Delta g = -(f''(r)+\frac{n-1}{r}f'(r))=0$
Solve this linear second order ODE to obtain:
$f(r)= \left\{ \begin{array}{ccc}
b\ln(r)+c & \text{if } n=2\\
\frac{b}{r^{n-2}}+c & \text{if } n\ge 3 \end{array} \right\} $
Put this back in terms of $x$ and you have your solution.
A: This doesn't really help with your chosen way to solve the problem, but it is a way to check the answer when you get it. It is geometric and intuitive, at least to me.
When I see words "harmonic function", I immediately think about taking integrals. Maybe it comes from physics, where electric potential $\varphi$ is harmonic (at places where there are no free charges), and people like to look at the flux of the electric field $\vec{E} = \nabla \varphi$ through closed surfaces.
So let's take some integrals. Since $u$ has spherical symmetry, let's take integrals over spheres.
Pick two numbers $0 < r_1 < r_2$ and look at two spheres $S_1 = \{x: |x| = r_1\}$ and $S_2 = \{x: |x| = r_2\}$. Between these two spheres is a spherical shell $D = \{x: r_1 \leq |x| \leq r_2 \}$. If we orient the spheres properly, then $\partial D = S_2 - S_1$. The minus sign means that the one sphere bounds the shell from the outside and the other from the inside.
Now let's go ahead and take the integral of $\Delta u$ over $D$. On the one hand it is zero, because $\Delta u = 0$. On the other hand it equals to the flux of the gradient $\nabla u$ by the divergence theorem. So we have:
$$
0 = \int_D \Delta u \cdot dV = \oint_{S_2-S_1} \vec{\nabla u} \cdot \vec{dS},
$$
therefore
$$
\oint_{S_1} \vec{\nabla u} \cdot \vec{dS} = \oint_{S_2} \vec{\nabla u} \cdot \vec{dS}.
$$
Now we play the symmetry card. Synce $u(x) = f(|x|)$, the gradient of $u$ at point $x$ is parallel to vector $x$, and its value is simply $f'(|x|)$. More precisely, $\vec{\nabla u}(x) = \frac{x}{|x|} f'(|x|)$. If we look at $\vec{\nabla u}$ when $x$ lies on the sphere $S_1$, $\vec{\nabla u}$ is orthogonal to the surface of the sphere, and its magnitude is constant on all the sphere. So taking the integral becomes simple multiplication:
$$
\oint_{S_1} \vec{\nabla u} \cdot \vec{dS} = f'(r_1) \cdot \alpha \cdot r_1^{N-1}.
$$
Here $\alpha \cdot r_1^{N-1}$ is the surface area of $S_1$. The exact value of constant $\alpha$ is not important. It's enough to know that $\alpha$ doesn't depend on the radius, and $\alpha \neq 0$.
Now, doing the same for the integral over $S_2$, we arrive at the equality:
$$
f'(r_1) \cdot \alpha \cdot r_1^{N-1} = f'(r_2) \cdot \alpha \cdot r_2^{N-1}.
$$
But this holds for any $0 < r_1 < r_2$. This simply means that
$$
f'(r) \cdot r^{N-1} = \text{const}.
$$
So, whatever solution you find for $f$, it must satisfy this differential equation. In fact, you'll probably come to the exact same equation when you do it your way.
NB: as it is, this text only proves that $f'(r) \cdot r^{N-1} = \text{const}$ is a necessary condition. You can extend it to prove sufficiency, but it's probably better to get sufficiency using your way, and use my way for insurance.
