Can a non-local ring have only two prime ideals?
Take $\dfrac{\mathbb{Z}}{6\mathbb{Z}}.$ There are 2 maximal ideals here $\frac{(2)}{(6)}$ and $\frac{(3)}{(6)}$, and these are the only ones.
Let $p$ and $q$ be two different prime ideals of $R$ of height zero. Set $S=R-(p\cup q)$ and consider $S^{-1} R.$ Maximal ideals are $S^{-1}p$ and $S^{-1}q $.
Note that there is a one-to-one correspondence between prime ideals of $S^{-1}R$ and prime ideals of $R$ which dont meet $S$ (3.11 of Atiyah-Macdonald).
If $(A,\mathfrak p)$ and $(B,\mathfrak q)$ are local rings with only one prime ideal, then $R=A\times B$ has this property: a prime ideal must contain either $(1,0)$ or $(0,1)$ since their product is $0$, and then it is easy to see the prime must be either $A\times\mathfrak q$ or $\mathfrak p\times B$, respectively. (More generally, if $R=A\times B$ for any two rings $A$ and $B$, the primes in $R$ are exactly the sets of the form $A\times \mathfrak q$ or $\mathfrak p\times B$ where $\mathfrak q$ is a prime of $B$ or $\mathfrak p$ is a prime of $A$.)
Conversely, every example has this form. Indeed, if $R$ is not local and has exactly two prime ideals, both prime ideals must be maximal. It follows that $\operatorname{Spec}(R)$ is a discrete space with two points $\mathfrak p$ and $\mathfrak q$. From the fact that the structure sheaf on $\operatorname{Spec}(R)$ is a sheaf it follows that the canonical map $R\to R_{\mathfrak p}\times R_{\mathfrak q}$ is an isomorphism (since $R_{\mathfrak p}$ is exactly the value of the structure sheaf on the open set $\{\mathfrak p\}$ and $R_{\mathfrak q}$ is exactly the value of the structure sheaf on the open set $\{\mathfrak q\}$).