More aerobic bacteria are found in the pancreas with tumors than in the healthy pancreas. We provide a mechanistic understanding of the migration of intestinal bacteria from the duodenum to the pancreas with tumors. Mathematical models of migration of aerobic bacteria from the duodenum to the pancreas with tumors in the hepatopancreatic duct were developed. In addition, the behaviors of GFP E. coli under a pH gradient in a microfluidic device were analyzed. Moreover, upstream migrations of Pseudomonas fluorescens against flow were measured in a polydimethylsiloxane (PDMS) T-shaped cylinder mimicking a pancreatic duct. The simulated bacterial concentration of the pancreas with tumors was higher than that of the healthy pancreas and agreed reasonably well with the literature. Migration of aerobic bacteria in the hepatopancreatic duct is counteracted by bile and pancreatic juice flow but facilitated greatly by bacterial pH taxis from lower pH in duodenum fluid toward slightly alkaline pH in pancreatic juice, favorable for them. Migration of bacteria to the pancreas with tumors is made easier by solid tumors on the pancreatic duct, which compresses the pancreatic duct and thus reduces the fluid flow rate. On the other hand, GFP E. coli migrated under the pH gradient in a microfluidic device from acidic areas toward neutral or slightly alkaline pH, validating pH taxis. Furthermore, Pseudomonas fluorescens migrated upstream from hydrochloride solution but not from bicarbonate solution against bicarbonate flow at >20 µm/s, with an advancing velocity of approximately 60 µm/s, validating the models (244 words).