Although fletch is spot on there, I don't agree with him thinking you should've folded preflop. You had a hand with potential, had half of the call already in the pot and great pot odds
to boot. Why fold there if there isn't any sort of raise?
You should've been more aggressive after the flop though. Even if you didn't have a made hand, you had a hell of a lot of ways to complete it and most likely could've taken the pot right there with a good enough bet. Be aggressive with good draws because even if you don't take it down there, you can still get there with two cards to come, and if you do it'll likely be a big payday.
Checking your draw and giving villian the free card is what cost you, and you probably would've been better checking after you hit your straight since you were OOP and someone was very likely to do your betting for you with a board texture like that. That would've been the time to put out some firepower.
I would've played the river more carefully too. Straight is good, but a paired board is very dangerous to a straight, especially when you make a sizable bet and get flat called. You gotta think the guy has SOMETHING. I probably would've checked the river there and called a small bet, but if he shoved I'd think twice.
Sometimes you gotta make the tough laydown based on the boards chemistry and how the hand played out, and the flat call on the turn was a red flag that said he's got something big, especially given the preflop flat call. It's almost dead obvious he was set mining.
I'm surprised villain didn't bet the flop though. There was only one overcard and he had a gutshot draw as well.
You didn't play the hand horrible, it was mostly a cooler. But if you were more aggressive on the flop you might've been able to win it there and avert a disaster. Really just tough luck what happened to you though.