Make sure your saddle is high enough. When the pedal is farthest from the saddle, and your leg is locked straight, keeping your hips level, you should be just able to brush the pedal with your heel.
Too- low saddle means your legs never get to fully extend, which is both weak and very hard on the knees. Imagine walking a mile with your legs bent in a crouch.
Pedal a higher cadence, at least 80 rpm. Means when cruising on the flat, being in the middle ring, not the big ring. As you get stronger you can try big ring riding, but if your knees hurt, back to the middle ring.
Too-big gears mean more force required, hence more stress on the knee and the rest of the legs, butt , etc.
Give cycling a rest for a week then resume, gently , using the above tips . If your knees hurt again, come back with more details or consult someone in person: a bike fitter and a sports doctor. Do not keep riding with pain or try to cover it up with pain meds.
The knee pain you're describing is not something to take lightly.