This is the _exact_ reason I went to grad school. I didn't believe I was a "good enough" chemical engineer so I went to grad school. About 2-3 years I was miserable but stuck with it to get the letters after my name. Thankfully my program pushes us to get out in under 5 years.
I also struggled with mental health during my PhD, but there were a lot of compounding factors. The PhD was fuel on the fire, but not the spark.
Now I've transitioned successfully into the "data science" field, so I'm much happier!