A New York City police detective has pleaded guilty to hacking into email accounts and accessing a federal law enforcement database without authorization.