The presence of numerous complex organic molecules (COMs; defined as those containing 6 or more atoms) around protostars shows that star formation is accompanied by an increase of molecular complexity. These COMs may be part of the material from which planetesimals and ultimately planets formed. Comets sample some of the oldest and most primitive material in the solar system, including ices, and are thus our best window into the volatile composition of the solar proto-planetary disk. Molecules identified to be present in cometary ices include water, simple hydrocarbons, oxygen, sulfur and nitrogen-bearing species, as well as a few COMs, such as ethylene glycol and glycine. Here, we report the detection of 21 molecules in comet C/2014 Q2 (Lovejoy), including the first identification of ethyl alcohol (ethanol, C2H5OH) and the simplest monosaccharide sugar glycolaldehyde (CH2OHCHO) in a comet. The abundances of ethanol and glycolaldehyde, respectively 5 and 0.8% relative to methanol (0.12 and 0.02% relative to water), are somewhat higher than values measured in solar-type protostars. Overall, the high abundance of COMs in cometary ices supports formation through grain-surface reactions in the solar system protoplanetary disk.