We discuss the equilibrium statistical mechanics of systems with long-range interactions. We contrast the microcanonical description of an isolated Hamiltonian system from the canonical description of a stochastically forced Brownian system. We show that the mean-field approximation is exact in a proper thermodynamic limit N→+∞. The one-point equilibrium distribution function is solution of an integrodifferential equation obtained from a static BBGKY-like hierarchy. It also optimizes a thermodynamical potential (entropy or free energy) under appropriate constraints. In the case of attractive potentials of interaction, we show the existence of a critical temperature Tc separating a homogeneous phase (T⩾Tc) from a clustered phase (T⩽Tc). The homogeneous phase becomes unstable for T<Tc and this instability is a generalization of the Jeans gravitational instability in astrophysics. We derive an expression of the two-body correlation function in the homogeneous phase and show that it diverges close to the critical point. One interest of our study is to provide general expressions valid for a wide class of potentials of interaction in various dimensions of space. Explicit results are given for self-gravitating systems, 2D vortices and for the HMF model.