Rings whose spectrum is Hausdorff 
Let $A$ be a commutative ring with $1$ and consider the Zariski topology on $\operatorname{Spec}(A)$. When will $\operatorname{Spec}(A)$ be a Hausdorff space?

If $A$ has positive or infinite Krull dimension, this can never happen because there are points which will be a proper subset of their closure. In dimension $0$, any Noetherian ring is also Artinian and thus has a discrete spectrum, which is therefore Hausdorff.
What about the non-Noetherian, zero-dimensional case? I suspect that there are such rings with a non-Hausdorff spec, but I failed to find an example.
 A: For an affine scheme $S=\operatorname{Spec}(A)$ the following are equivalent: 
1)   $A$ is zero-dimensional
2) $S$ has all its points closed (i.e. $S$ is $T_1$)
3)  $S$ is Hausdorff
4)  $S$ is compact Hausdorff 
If moreover the ring $A$ is noetherian  the above are also equivalent to:
5) $A$ is Artinian
6) $S$ has the discrete topology
7) $S$ is finite and has the discrete topology
If moreover the ring $A$ is finitely generated over a field $k$ (and thus noetherian) the above are also equivalent to:  
8)  $A$ is algebraic over $k$
9) $ \text {dim}_k(A)\lt \infty$
10) $\text {Card}(S)\lt \infty$       
Examples of non-noetherian rings satisfying 1) to 4):
Any infinite product of any fields $A=\Pi_{i\in I} K_i$ ($I$ infinite)
Examples of noetherian rings which are not algebras over a field but satisfy 1) to 7):
$\mathbb Z/(n)$ with $n\gt 1$ and not prime.
A: The accepted answer is very satisfactory, but I realized that it was not that easy to find a reference that contains an actual proof of the equivalence between "$A$ is zero-dimensional" and "$\operatorname{Spec}(A)$ is Hausdorff". The reference given in one of the previous comments gives a completely broken proof, and it seems that the best option is to go back to Hochster's original article on the topology of spectral spaces. But that article is written in a purely topological language, and it can take a little work to translate everything in the language of rings, so I'm writing a self-contained proof here that can serve as a reference.

Theorem 1: Let $R$ be a commutative ring. Then $\operatorname{Spec}(R)$ is Hausdorff if and only if $R$ is zero-dimensional, in other words when every prime ideal of $R$ is maximal.

Obviously, only the direction "zero-dimensional implies Hausdorff" is non-trivial, since $R$ being zero-dimensional is equivalent to all prime ideals being maximal, in other words to all points in $\operatorname{Spec}(R)$ being closed, that is to $\operatorname{Spec}(R)$ satisfying the $T_1$ separation axiom, which is obviously weaker that the $T_2$ (Hausdorff) axiom.
It's actually not much harder to prove a deeper fact about separation in ring spectra:

Theorem 2: Let $R$ be a commutative ring, and let $p,q\in \operatorname{Spec}(R)$. Then exactly one of those two things holds:

*

*$p$ and $q$ admit disjoint neighborhoods in $\operatorname{Spec}(R)$;

*$p$ and $q$ both belong to the closure of a third point.


It is easy to see that Theorem 2 implies Theorem 1: indeed, if $\operatorname{Spec}(X)$ is $T_1$, then the closure of a point is just that point, so the second case in Theorem 2 happens iff $p=q$, and therefore distinct points have disjoint neighborhoods.
Now let us translate those two topological statements. If $x,y\in \operatorname{Spec}(R)$, then $y$ is in the closure of $x$ (one also says that $y$ is a specialization of $x$) if and only if $x\subset y$ as ideals. This is because the closure of $x$ (or rather of $\{x\}$) is the smallest $V(I)$, with $I$ an ideal, such that $x\in V(I)$, so $I$ is the largest ideal such that $I\subset x$, and obviously that is $I=x$; therefore $\overline{\{x\}} = V(x)$.
For the second statement, note that $\operatorname{Spec}(R)$ has an open basis given by the $D(f)=\{x\in \operatorname{Spec}(R) | f\not\in x\}$. So saying that $p$ and $q$ admit disjoint neighborhoods amounts to finding $f,g\in R$ such that $f\not\in p$ (ie $p\in D(f)$), $g\not\in q$ (ie $q\in D(g)$), and any prime ideal of $R$ contains at least one of $f$ or $g$ (ie $D(f)\cap D(g)=\emptyset$).
So we can reformulate Theorem 2 with an equivalent statement:

Theorem 3: Let $R$ be a commutative ring, and let $p,q\subset R$ be prime ideals. Then exactly one of those two things holds:

*

*there exist $f,g\in R$ with $f\not\in p$, $g\not\in q$, and every prime ideal of $R$ contains $f$ or $g$;

*there exists a prime ideal contained in $p\cap q$.


Topology put aside, it is very clear that those two things are incompatible: if $I\subset p\cap q$ is prime, $f\not\in p$ and $g\not\in q$, then clearly $I$ contains neither $f$ nor $g$. So to prove Theorem 3 we will assume that the first alternative fails, and show that the second holds.
Let us then assume that for all $f,g\in R$ such that $f\not\in p$ and $g\not\in q$, there exists a prime ideal $I\subset R$ which contains neither $f$ nor $g$. We will construct a prime ideal $J$ such that $J\subset p\cap q$.
Let $X = \operatorname{Spec}(R)\setminus (p\cap q)$. We want a prime ideal $J$ such that $J\cap X=\emptyset$. Of course, such a $J$ satisfies the weaker property that for any finite $A\subset X$, there is a prime ideal $I$ with $J\subset I$ and $I\cap A=\emptyset$ (just take $I=J$). Let us say that some subset $Y\subset R$ is a candidate if it satisfies this weaker property.
From the hypothesis, we can already see there is at least one candidate: $Y=\emptyset$. Indeed, by definition of $X$ the elements of some finite $A\subset X$ can be divided in some $f_i$ with $f_i\not\in p$ and some $g_i$ with $g_i\not\in q$. Then $f=\prod_i f_i$ is not in $p$ (since $p$ is prime) and $g= \prod_i g_i$ is not in $q$, so there exists a prime $I$ which contains neither $f$ nor $g$, and therefore $I\cap A=\emptyset$ (and of course $Y=\emptyset \subset I$).
Now by Zorn's lemma we can take a maximal candidate (for inclusion), and call it $J$. We then show that $J$ is a prime ideal contained in $p\cap q$. First note that by construction any candidate is disjoint with $X$, and therefore is contained in $p\cap q$. Also, it is trivial to see that if $Y$ is a candidate, then the ideal generated by $Y$ is also a candidate; therefore by maximality $J$ must be an ideal.
It remains to show that $J$ is prime. Let $f,g\in J$ such that $fg\in J$ but $g\not\in J$. We show that $J\cup \{f\}$ is a candidate, which by maximality will mean that $f\in J$. By maximality, $J\cup \{g\}$ is not a candidate, which means there exists a finite $A_0\subset X$ such that for any prime ideal $I$, if $J\subset I$ and $g\in I$ then $I\cap A_0\neq \emptyset$. Now let $A\subset X$ be finite. By hypothesis we have a prime $I$ such that $J\subset I$ and $I\cap (A\cup A_0)=\emptyset$. By choice of $A_0$, it is then not possible that $g\in I$. But since $fg\in J$, we have $fg\in I$, so since $I$ is prime we must have $f\in I$. This shows that $J\cup\{f\}\subset I$, and $I\cap A=\emptyset$, so $J\cup \{f\}$ is indeed a candidate, and we are done.
