Mayor Bill de Blasio’s social media director abruptly quit after less than two months on the job — and took to Facebook to say he resigned “for the sake of my health and my sanity.”

Scott Kleinberg, who left a longtime journalism career at the Chicago Tribune to move to New York City in May, posted Wednesday morning that “I ended up with political hacks plus a boss who just couldn’t get it.”

“It was a bad combination for sure,” he said, adding that he’s now unemployed.

A May 3 email from de Blasio’s office announcing Kleinberg’s hiring as “Director of Social Media and Digital Engagement” said “Kleinberg and his team will infuse personality and engagement into the social media channels.”

In the Facebook post publicizing his exit, Kleinberg said: “Well, that was fast. I moved to NYC for a dream job and that’s not what I got. I tried to stick it out, but it was impossible.”

The mayor’s office said in a statement: “New York City government is a tough, fast-paced job that is not for everyone. We wish him well.” Spokesman Eric Phillips said that Kleinberg’s boss was Rob Bennett, a former Wall Street Journal photographer who had been de Blasio’s photographer until being assigned to be creative communications director. Phillips said a “public search” would be conducted to replace Kleinberg.

Reached by phone, Kleinberg said that as a longtime journalist he appreciated the reason for the call but declined to comment.

“I couldn’t post anything without getting it approved. Crazy but true. Just one of the many things wrong with everything,” he said in response to one of more than 150 comments, nearly all supportive. Kleinberg said he was planning to stay in New York City and was seeking work elsewhere.

“I’ve learned a lot in the past several weeks,” he said, “including something I’ve ignored in many a fortune cookie: If something seems too good to be true, it probably is.”

A spokesman for Brad Tusk, Michael Bloomberg’s former campaign manager who has been leading an effort to stop de Blasio’s re-election, issued a news release promising to help Kleinberg find another job.

“He — along with every New Yorker — deserves better,” the statement said.