Stochastic Differential Equation solution for Geometric Brownian Motion
Your integration step is wrong. $Z$ here refers to Brownian motion, and thus you need to apply Ito Integration.
One way I like to see the extra drift is needed, is that we take derivative of the integration result, and see if they match the SDE or not, using Ito Lemma.
So if $Y_t =f(t, Z_t)$, with $f(t,z)=f(0, Z_0)e^{(\mu-\frac{\sigma^2}{2})t+\sigma z}$, where $Z_t$ is an adapted stochastic process, we have:
$$dY_t=df(t, Z_t)=\frac{\partial f(t, Z_t)}{\partial t} dt+ \frac{\partial f(t, Z_t)}{\partial z}dZ_t + \frac{1}{2} \cdot\frac{\partial^2 f(t, Z_t)}{\partial z^2}(dZ_t)^2$$
And for $Z_t$ being Brownian motion, we also have $(dZ_t)^2=dt$
Now let's plug in for the question here: $$Y_t= Y_t(0)e^{(\mu-\frac{\sigma^2}{2})t+\sigma Z_t}$$
$$dY_t=(\mu-\frac{\sigma^2}{2})Y_tdt + \sigma Y_tdZ_t + \frac{1}{2}\sigma\sigma Y_t(dZ_t)^2$$ $$=(\mu-\frac{\sigma^2}{2})Y_tdt + \sigma Y_tdZ_t + \frac{1}{2}\sigma^2 Y_tdt$$ Thus $$dY_t=\mu Y_tdt + \sigma Y_tdZ_t$$
Which means that the $Y$ we get is the solution for the SDE.
EDIT
So OP wants to solve instead of see why that extra drift exists. Basically integration and derivative are the same thing, just notations:
So the following integration is Ito, $Y$ is not smooth enough for you to apply the calculus rule you are familiar with. $$\int \frac{dY}{Y} \color{red}\ne \ln(Y)$$
Notice $$d(\ln Y)=\frac{dY}{Y} -\frac{1}{2}\frac{1}{Y^2}(dY )^2$$
$$(dY)^2=(\mu Y_tdt + \sigma Y_tdZ_t)^2=\sigma^2Y^2 dt$$ We also know $\frac{dY}{Y}$ from our original SDE.
Plug them in and we get:
$$d(\ln Y)=\mu dt + \sigma dZ-\frac{\sigma^2}{2} dt$$
Now the right-hand-side do not have $Y$, you'll be able to solve it, i.e.
$$\ln Y_t - \ln Y_0 = \int_0^t d(\ln Y) = \int_0^t (\mu -\frac{\sigma^2}{2})dt + \int_0^t \sigma dZ_t=(\mu -\frac{\sigma^2}{2})t + \sigma Z_t$$