When a current flows in a wire, it creates a circular magnetic field around the wire. This magnetic field can deflect the needle of a magnetic compass. The strength of the magnetic field is greater:
closer to the wire
if the current is increased
A solenoid consists of a wire coiled up into a spiral shape. When an electric current flows, the shape of the magnetic field is very similar to the field of a bar magnet. The field inside a solenoid is strong and uniform. The small magnetic fields caused by the current in each coil add together to make a stronger overall magnetic field.