Or is this something from Romance of the Three Kingdoms?
Oohh, I can't believe twice in one month my obscure encyclopedic knowledge of Three Kingdoms historiography is going to come in handy!
The basic answer is: it might have happened, but if it did the context is different.
First of all, let's visit the common story in the Romance of the Three Kingdoms:
-Cao Cao is arrested on the run after a failed assassination attempt on Dong Zhuo
-Cao Cao is released by his sympathetic captor and later enemy Chen Gong, who admires his opposition to Dong Zhuo
-Cao Cao & Chen Gong flee and take refuge with Lu Boshe - a friend of Cao Cao's father
-Whilst sleeping in the guest room, Cao Cao hears the sounds of knives being sharpened, and hears people whispering about killing them
-Cao Cao bursts out of his room sword drawn, kills the entire family until he realizes they were sharpening their knives and preparing to kill a pig for a feast to welcome Cao Cao & Chen Gong
-Full of regret Cao & Chen flee, but on their way they run into Lu Boshe who is returning from town with booze for the welcoming party, Lu Boshe asks why Cao & Chen are leaving so soon
-Cao kills Lu Boshe, Chen admonishes him, saying the first killings was a mistake, but this was intentional
-Cao says that they must kill Lu Boshe or else when Lu has found out the fate of his family he will seek revenge, then laughs coldly and says the famous line 寧教我負天下人,休教天下人負我 "I would rather betray the world than let the people of the world betray me"
-Chen realizes that Cao is a monster and leaves him and later becomes his enemy
NOW, let's get onto history. The primary source of this era is Records of the Three Kingdoms by Chen Shou, which for brevity I'll just call RTK. This event is not mentioned in RTK, at all. Although both Cao & Chen have quite detailed biographies within RTK. However, it would not be incredibly surprising if this were the case as RTK was a fairly official compilation of earlier records in the Jin Dynasty, who drew their legitimacy from Cao Cao's State of Wei, which means that they are fairly pro-Cao Cao, and this story makes Cao Cao look pretty bad.
So, the next step for Three Kingdoms historiography once RTK is exhausted is to look at all the other historical chronicles that overlap with the era. And here this story does start appearing - in the Book of Wei, the Shiyu & the Sunsheng Zaji (which I'll just call Zaji for short).
A word on these sources, RTK is considered an incredibly reliable and credible source as it was worked over by so many historians and chroniclers, and more importantly there is a running commentary by a secondary later historian Pei Songzhi running through it, who talks about the biases inherent in each chronicle and whether things lines up. But for the purposes of 3rd-4th Century AD it is an impeccable piece of history. But the more you go on these other sources the less reliable they get, in terms of reporting hearsay, in terms of not disclaiming biases, in terms of not doing field work to verify things.
So what do these three sources seem to agree on, and how does that differ from the Romance of the Three Kingdoms version?
-Cao Cao is arrested on the run after a failed assassination attempt on Dong Zhuo after fleeing the capital due to his opposition to Dong Zhuo
-Cao Cao is released by his sympathetic captor and later enemy Chen Gong, who admires his opposition to Dong Zhuo whose name and identity is unknown
-Cao Cao & Chen Gong a few followers flee and take refuge with Lu Boshe - a friend of Cao Cao's father although Lu Boshe was not there, just his household
-Depending on which source you follow: Whilst sleeping in the guest room, Cao Cao hears the sounds of knives being sharpened, and hears people whispering about killing them and grows suspicious (Zaji) OR people from the household tried to rob him (Book of Wei)
-Cao Cao bursts out of his room sword drawn, kills the entire family until he realizes they were sharpening their knives and preparing to kill a pig for a feast to welcome Cao Cao & Chen Gong Cao Cao kills several members of the household and escapes
-Full of regret Cao & Chen flee, but on their way they run into Lu Boshe who is returning from town with booze for the welcoming party, Lu Boshe asks why Cao & Chen are leaving so soon
-Cao kills Lu Boshe, Chen admonishes him, saying the first killings was a mistake, but this was intentional
-Cao says then laughs coldly and says the famous line 寧教我負天下人,休教天下人負我 "I would rather betray the world than let the people of the world betray me"
-Chen realizes that Cao is a monster and leaves him and later becomes his enemy
Wow, different story right? Basically all three sources say: Cao fled to a house belonging to the friend of his father, then he was either attacked or grew overly paranoid, killed a few people in the household out of either self defense or paranoia and then fled. Lu Boshe was not there, neither was Chen Gong. The two characters were added into Romance of the Three Kingdoms to:
a) Show just how evil Cao Cao was, the killing of Lu Boshe is a sin for killing the head of the household you're guest in, not to mention your father's friend, and it was completely intentional
b) Chen Gong was in there to kind of give the readers a moral angle via which to condemn Cao Cao.
But what about the famous line? Well, the Book of Wei which is still seen as fairly reliable if a little pro Cao Cao, does not mention it. Shiyu which is a little less credible but more anti Cao Cao also does not mention it. Zaji, also less credible but more anti Cao Cao, DOES mention it, but it's very different.
Instead of Cao Cao laughing coldy and defiantly and saying "I would rather betray the world than let the people of the world betray me"
We have
" 旣而悽愴曰:「寧我負人,毋人負我!」遂行" which translates to "Afterwards (having mistakenly killed people), he said with great sadness/regret 'better I have wronged others than others have wronged me' and quickly fled"
Which I'm sure we can agree is a natural response - somebody mistakenly killing a group of friends out of paranoia & fear, reacting with great remorse (the word 悽愴 is the strongest negative emotion possible, you use that word when you want to portray somebody who is heart broken and crying openly) and then deflecting his crimes by claiming it's better than the other way around. Altogether a much more human story compared to the version in Romance of the Three Kingdoms. And this from a relatively anti Cao Cao historical source.
TL;DR: So there's your summary: the killings probably did happen (but only the first ones which was either an accident or self defense, not the second one which was a coverup), but it was nowhere as villainous an event as the Romance made it out to be but more a tragic story (or if you go by the Book of Wei it's not even tragic, just self defense). The quote may or may not have happened, I think most modern Three Kingdoms scholars lean towards it not happening due to lack of a second source. If it did happen, it happened in a much more sympathize-able circumstance and made Cao Cao very human instead of this larger than life once in a dynasty great antagonist.