You didn't start a PhD because you thought it would be easy. You knew it would take time, and you knew it would involve difficulties along the way.
But, still, it's easy to get frustrated when things don't go your way.
During my own PhD, I felt demotivated because I wasn't getting results as quickly as others were. I got frustrated when experiments didn't work, and I never fully invested myself because I didn't want to take the risk.
Of course, these responses were the opposite of what was needed. It was only when I slowed down and started doing things carefully, without worrying about the end result, that my fortunes changed.
I developed the patience to do things slowly and the persistence to keep trying. And, crucially, I maintained these attitudes when I faced challenges throughout the rest of my PhD.
The challenges you face in your PhD are really just tests of your patience and persistence. How will you respond?