Your first definition is a sample variance. The second might also be the sample variance or it might be a calculation of the variance for a discrete valued random variable with equiprobable outcomes. (saying more would require context.)
Population Variance:
The population variance (or simply variance) is defined as:
$$ \mathrm{Var}(x) = \mathrm{E}\left[ \left( x - \mathrm{E}[x] \right)^2 \right] $$
Special case ($x$ is a discrete valued random variable):
For a random variable $x$ which takes only discrete values, the expectation is a sum and can be written as:
$$ \mathrm{Var}(x) = \sum_i p_i (x_i - \mathrm{E}[x])^2 \quad \quad \mathrm{E}[x] = \sum_i p_i x_i$$
where $p_i$ is the probability of outcome $x_i$.
Even more special case:
A further special case is when each outcome is equally probable (eg. a dice role) in which case $p_i = \frac{1}{n}$ hence $ \mathrm{Var}(x) = \frac{1}{n} \sum_i (x_i - \mathrm{E}[x])^2 $ where $\mathrm{E}[x] = \frac{1}{n}\sum_i x_i$
Sample Variance:
Let's say you have $n$ independent and identically distributed observations $x_i$. Your set of $\{x_i\}$ form a sample. The sample mean is given by:
$$ \bar{x} = \frac{1}{n} \sum_{i=1}^n x_i$$
The sample mean is the mean of the sample. It is also an estimate of the population mean $E[x]$.
Similarly, we can compute the sample variance.
$$\frac{1}{n-1} \sum_i \left(x_i - \bar{x} \right)^2 \quad \text{ where } \quad \bar{x} = \frac{1}{n} \sum x_i$$
The $n-1$ here is a degrees of freedom correction. If you're confused by it, don't worry too much. It's a technical correction so that expectation of the sample variance is the population variance. The idea is that your estimate of the sample variance is based upon $n-1$ observations instead of $n$ (intuition: if you had $n=1$ observations, then $x_1 = \bar{x}$! In some sense, one degree of freedom in your datagets used up when you demean your series (i.e. subtract off the sample mean).
Another technical note is that sometimes $\frac{1}{n} \sum_i \left( x_i - \bar{x} \right)^2$ is used as the sample variance (i.e. not everyone makes the degrees of freedom correction and in large samples, it doesn't matter).
Wikipedia has a whole section on population vs. sample variance here.