An electrochemical assay was developed for β-D-galactosidase in coliform bacteria Escherichia coli (E. coli) using p-aminophenyl-β-D-galactopyranoside (PAPG) as substrate. The hydrolysis of PAPG by pure β-D-galactosidase was investigated based on the cyclic voltammetric (CV) behavior of p-aminophenyl (PAP). The results obtained using the pure enzyme showed that the addition of magnesium ion facilitated the enzyme-catalytic reaction. Km at the optimal magnesium ion concentration (5 mmol/L) was 0.90 mmol/L. The substrate was also used for coliform bacteria, where β-D-galactosidase in the bacteria cells was strongly induced by isopropyl-β-D-thiogalactopyranoside (IPTG). When the E. coli cell density exceeded 1.1 × 10 mL−1, the CV response was linearly related to the number of E. coli, the detection time was about one hour. This method can be developed into a portable biosensor for rapid assay of coliform bacteria.