Q:

1 = 0 finding the mistake

I was shown the following calculation. There is clearly something wrong but I can not see the mistake. Could someone point out the wrong step or something?
$$ \int \frac{1}{x} dx = \int 1 \cdot \frac{1}{x} dx$$
Let's say $ u = \frac{1}{x}$ and $ dv = 1\ dx$.
So $ du = -\frac{1}{x^2} \ dx$ and $ v = x$.
Putting that into per partes formula:
$$ \int \frac{1}{x} dx = \int 1 \cdot \frac{1}{x} dx= x \cdot \frac{1}{x} - \int x \cdot (-\frac{1}{x^2})dx = 1 + \int \frac{1}{x} dx$$
So we can substract $\int \frac{1}{x}dx$ from both sides which then gives us
$$0 = 1$$

A:

You are forgetting the constant of integration. When you write $\int\frac1xdx$, that could represent any of a family of functions. So in this case, the left-hand $\int\frac1x dx$ represents an antiderivative of $\frac1x$ which is $1$ larger than the $\int \frac1xdx$ on the right-hand side. This also means that you cannot "subtract $\int\frac1xdx$" as easily as you might think.
The moment you put bounds on your integrals, everything changes. In that case (assuming the bounds are valid), we get
$$
\int_a^b\frac1xdx = 1\Big|_{x = a}^b + \int_a^b\frac1xdx
$$
and we see that the $1|_a^b$ term disappears, and all is well.

