example of a flat but not faithfully flat ring extension

Take $f: A \rightarrow B$ to be a ring homomorphism such that the corresponding morphism of affine schemes $\operatorname{Spec}B \rightarrow \operatorname{Spec}A$ is not surjective, but only flat. There is an easy way to do this: Remember that localizing a ring $R$ in a multiplicative subset $S$ gives a flat ring homomorphism $R \rightarrow S^{-1}R$. However, this ring homomorphism is faithfully flat iff $S^{-1}R=R$.


$0$ is always flat, but not faithfully flat (unless the base is $0$).


A possibly instructive, concrete example is $\Bbb{Q}$ as an abelian group (i.e. as a $\Bbb{Z}$-module). Of course, this is just a special case of Dedalus's answer (and YACP's comment), but let's still prove the result directly.

Clearly $\Bbb{Q}$ is not a faithfully flat abelian group, e.g. the zero morphism $$ \Bbb{Z}/2\Bbb{Z} \rightarrow 0 $$ is not injective, but after tensoring with $\Bbb{Q}$ this morphism is the identity on the zero group (as $\Bbb{Z}/2\Bbb{Z} \otimes \Bbb{Q} \cong 0$).

On the other hand, $\Bbb{Q}$ is a flat abelian group. To see this, assume that $$ f: A \hookrightarrow B $$ is an injective morphism of abelian groups, and consider the induced morphism $$ f \otimes id: A \otimes \Bbb{Q} \rightarrow B \otimes \Bbb{Q} $$ Now for $b \in B$ the element $b \otimes 1 \in B \otimes \Bbb{Q}$ is equal to zero, if and only if $b$ is torsion. So the kernel of $f \otimes id$ consists precisely of the elements $f(a) \otimes id$, such that $f(a)$ is torsion. But injectivity of $f$ implies that $a$ must be torsion as well, i.e. $a \otimes 1=0$. This shows that $f \otimes id$ is injective, and therefore $\Bbb{Q}$ is a flat abelian group.