  We study the Tur\'an number of long cycles in random graphs and in
pseudo-random graphs. Denote by $ex(G(n,p),H)$ the random variable counting the
number of edges in a largest subgraph of $G(n,p)$ without a copy of $H$. We
determine the asymptotic value of $ex(G(n,p), C_t)$ where $C_t$ is a cycle of
length $t$, for $p\geq \frac Cn$ and $A \log n \leq t \leq (1 - \varepsilon)n$.
The typical behavior of $ex(G(n,p), C_t)$ depends substantially on the parity
of $t$. In particular, our results match the classical result of Woodall on the
Tur\'an number of long cycles, and can be seen as its random version, showing
that the transference principle holds here as well. In fact, our techniques
apply in a more general sparse pseudo-random setting. We also prove a
robustness-type result, showing the likely existence of cycles of prescribed
lengths in a random subgraph of a graph with a nearly optimal density.
