# Gravity acceleration and hydrostatic pressure

I know that hydrostatic pressure $P$ is directly proportional to density $\rho$ and depth $h$. Why does $P$ depend on gravitational acceleration $g$ ?

$P=\rho g h$

Is it because the force of the water columns is related to the weight? But then where would the surface be in the formula?

$P = h \rho g$ ($\rho$ is density) is an approximation that can only be used when both $\rho$ and $g$ are constant over the height change $h$.
The accurate relationship is proven in most standard texts on the subject and indeed on the wikipedia page for hydrostatic equilbrium, by considering the equilibrium of a thin slab of thickness $\Delta h$ and area $A$.
What is found is that $$\frac{dP}{dh} = - \rho g,$$ where both $\rho$ and $g$ may be a function of $h$. The simple formula is obtained by assuming they are constant and integrating from a depth $-h$ to zero.