The only modern president who rivaled Donald Trump in his lack of preparation for global leadership was Harry Truman. Both men took office with little knowledge of the international problems they were about to face, and with worries at home and abroad that they weren’t up to the job.

“I pray God I can measure up to the task,” Truman said right after Franklin Roosevelt’s death and the shock of taking the oath of office. Trump wouldn’t be human if he hadn’t had a similar prayer in a corner of his mind on Jan. 20.

Now, in one of those curious rhymes of history, Trump faces a similar challenge to Truman’s in confronting North Korea. Truman went to war in 1950 to reverse a North Korean invasion of the South. Trump is now perilously close to conflict in his attempt to halt North Korea’s defiant nuclear program.

What can today’s occupant of the White House learn from Truman? The Missourian had many qualities now celebrated by historians, but let’s focus on his personal character. Truman exhibited what in those days were called manly virtues — quiet leadership, fidelity to his beliefs, a disdain for public braggadocio. He never took credit for things he hadn’t accomplished. He never blamed others for his mistakes.

President Trump is obviously a radically different person from Truman. He’s a showy New Yorker, where Truman was a low-key Missouri farm boy. Where Trump made his name as a noisy casino tycoon and TV star, the poker-playing Truman always kept his cards close.

(Adriana Usero/The Washington Post)

What these two presidents have in common is the experience of coming into the Oval Office facing widespread doubts. What Truman teaches us is that character counts, especially for a president with low initial popularity ratings.

On foreign policy, Trump has shown a flexibility and pragmatism that contradict some of his inflammatory campaign rhetoric. He had accused China of “raping” the American economy, for example, but as president, he evidently realized that he needed Beijing’s help on North Korea and other issues and dropped his claims that Beijing was a “currency manipulator.”

Trump’s Russia position seems to be evolving, too. During the campaign, he was almost fawning in his praise for President Vladimir Putin, and investigators probed for hidden connections to Russia’s covert hacking of the 2016 campaign. Now Trump has taken a warier tone toward Putin. There have been similar shifts on more mundane issues, such as the Export-Import Bank and the tenure of Federal Reserve Chair Janet L. Yellen.

Trump’s new positions seem right to me. But because they represent reversals from earlier views, they raise the question of what this man really believes.

How does a politician become more trustworthy? There’s no formula; it must be earned. But Trump would help himself if he exhibited more of the virtues that Truman embodied. Trump should stop blaming others, for starters. He should never again say that Barack Obama is the cause of his difficulties in Syria, or anywhere else. Shifting blame sounds political, but it also sounds weak. Similarly, Trump should never again malign his military commanders, as he did after the death of Navy SEAL William “Ryan” Owens, when Trump said that “the generals . . . lost Ryan.” Such statements are the opposite of leadership.

Trump should stop taking credit for things he didn’t do (and even for things he did accomplish). These boasts only diminish him. It’s good that he has decided that NATO isn’t obsolete anymore, but he’s foolishly vain to take credit for it. The same is true with job gains from decisions by U.S. companies to keep plants in the United States. The quicker Trump is to claim personal credit, the phonier it seems.

Trump’s taxes present another example of how trust is won and lost. The man running for president might refuse to release his tax returns, but the wise chief executive, never.

When presidents encounter difficulty, they need public confidence. Divisive tactics that may work in a campaign, or attempts to shift responsibility to others, can be ruinous. Truman is remembered as a great president because he overcame a history of personal failure, as a farmer and a haberdasher, to develop the one bond that’s indispensable for a president, which is that in a crisis, people believed him.

Truman was grieved by North Korea’s invasion in 1950. The war went badly, his popularity plummeted, his commander, Gen. Douglas MacArthur, defied him. But the public stuck with Truman for a simple reason: He had built a reservoir of the trust that is essential for a successful leader.

Read more from David Ignatius’s archive, follow him on Twitter or subscribe to his updates on Facebook.