You can go by steps. Suppose that $G$ is abelian. By classification (or by hand) the group is $C_2^3,C_4\times C_2, C_8$. Suppose $G$ is nonabelian. Then there is no element of order $8$, and not every element can be of order $2$. There is thus an element $a$ of order $4$, and $\langle a \rangle$ is a normal subgroup of $G$. Suppose now there is a unique element of order $2$, then this element must be $a^2$. Since we're short of elements, and there is a unique element of order $2$, there must exist an element $b$ of order $4$, and $b^2=a^2$. Since both $\langle a \rangle$ and $\langle b\rangle $ are normal, $bab^{-1}=a^i$ for some $i$. Since $i$ cannot be $1$ (for $G$ is nonabelian), and since $a$ has order $4$, so does $bab^{-1}$, hence $bab^{-1}=a^{-1}$. This the presentation $$G=\langle a,b\mid a^4=1,b^2=a^2,bab^{-1}=a^{-1}\rangle $$
of the quaternion group (although one should check this!). If there is not a unique element of order $2$, pick $b$ an element of order two different from $a^2$ and argue similarly to obtain a presentation of $D_4$.