I tried to use an example U8g2 library code to test out my 12864B LCD but it happened that it would show an image for a few seconds and then shut off showing just a blue screen.
I had it for a while but never used it. Maybe that caused the issue?
I tried to change the potentiometer settings without sucess.
As @xfpd said check the wires l. The wires connection should be tight to reduce error in data transmission.
Also try uploading different examples and check if they work properly
I made it work by connecting the LCD directly to the arduino but hasn´t managed to make it work with a breadboard yet.
I was able to upload and run the test codes that come with U8g2 library.