The forcible coercion shanghai is first attested in 1871 to describe the horrifying practice of forcing unwilling people to become deckhands, most often taken from SF and Portland onto ships bound for Shanghai. Mid-to-late 1800s ships required many deckhands to sail, but recruitment had a tough time competing with the gold rush. You can get a sense of how common this practice was was through the enactment of several federal laws against it across multiple decades. The change that finally ended the practice was the spread of steamships that required much less unskilled labor to operate.
Shanghai is a romanization of the Mandarin pronunciation of 上海 (Shànghǎi), with 上 (Shàng) meaning “upon” and 海 (hǎi) meaning “sea” for a gloss of “On the Sea”. The city of Shanghai got its current name in 1280, with speculation that the city was below sea level at the time. It was likely founded before the common era as a fishing village named 沪 (Hù).