I work in the tech startup industry, where a common saying is that the real way to make money during a gold rush is to sell shovels (the message for tech startups is that the best way to make money is to make a product to sell to other tech startups).
Is there any truth to this saying? During the California gold rush, was selling shovels (and other related equipment) more likely to provide a solid financial return than mining for gold?
The short answer is we really don't know.
Outside of word of mouth and the strikes that were notable enough to make news, we don't have a good idea of how much gold was really found as the lack of law enforcement and the hardships in filing a claim meant that miners were tight lipped about the locations and size of any strikes they might have made. There are estimates based on assayers records when they purchased gold, but that is limited as gold in itself was a currency and not always exchanged for cash or credit. We don't have any accurate numbers on how many people made a fortune, or even just made enough to come out ahead outside of journals and newspaper articles.
The second real problem in this question is that there wasn't just one California Gold Rush, there were multiple ones. By the standards of Gold rushes just few years later, Sutter's Mill (the first one,) is positively puny. In the first gold rushes most people definitely made money off mining. But a lot learned quickly that good money was made selling goods and services to miners and less than two years later merchants were setting up shops near major gold strikes within days of one being reported.
Additionally, there are stories of farmers taking herds of cattle and sheep, wagons of wheat and even eggs from Oregon's Willamette Valley to the California gold fields and making lots of money that way. Later on timber was another big export, creating the Pacific Northwest's early Timber Industry. Lots of coastal towns exported fish and dairy products to the gold fields. Some people even made money off building wagons and ships to transport all these goods.
Within a pretty short amount of time an industry sprung up around reselling claims. People would search one out, pan or mine them long enough to confirm it was a good place and then sell the claim to another miner or mining company. This is still an actual business methodology here in the United States BTW as the demand for gold in electronics keeps increasing.
The other places to make real money in those days was in prostitution and taverns. Stories abound of both arriving before merchants were even able to setup shop near gold strikes. I even have family stories of an ancestor who made his "fortune" just sweeping up the town's two taverns early in the morning and then panning the dust for gold.
Another place that people made money directly or indirectly off of mining in those days was selling land. People would make a land claim, hold and then sell it as little as a month later. Or they would sub-divide it to sell pieces to newcomers, or even incorporate a town on a portion of it. Many of these towns disappeared quickly, leaving only a place name, but the larger portion of cities in California and Oregon were built directly or indirectly off of gold mining. Early investors in successful town sites made money buying and selling town lots.
To answer your question more directly, I think the real answer is the best way to make money is by identifying a niche and filling it.