Let $A,B$ be two diagonal $n \times n$ matrices over some field $R$. And let $A$ and $B$ have the same eigenvalues (equal spectra) (in other words, each diagonal entry in $A$ is a diagonal entry in $B$ and vice-versa).
Then there should exist an invertible matrix $U$ that transforms $A$ to $B$ (i.e., $A = UBU^{-1}$), right?
Edit: Each eigenvalue in $A$ does not necessarily have the same multiplicity as each eigenvalue of $B$. So they don't necessarily have equal diagonals (up to permutation), just equal spectra.
The answer depends on whether you regard the spectrum of a matrix as a set (probably the more common definition) or a multiset, that is, whether the spectrum also encodes the (algebraic) multiplicities of the eigenvalues. (Somewhat confusingly, the Wikipedia article Spectrum of a matrix gives both definitions in different places but without further comment about this issue.)
If two diagonal matrices, say, $\Lambda := \operatorname{diag}(\lambda_i)$ and $\operatorname{M} := \operatorname{diag}(\mu_i)$, have the same eigenvalues (diagonal entries) including multiplicity—that is, if they have the same spectra as multisets—then there is a permutation $\sigma$ such that $\mu_i = \lambda_{\sigma(i)}$, and so $\Lambda$ and $\operatorname{M}$ are similar via the permutation matrix corresponding to $\sigma$.
On the other hand, if at least some of the eigenvalues have different multiplicities, then the matrices are not similar. For example, the matrices $$\operatorname{diag}(0, 0, 1) \qquad \textrm{and} \qquad \operatorname{diag}(0, 1, 1)$$ have different ranks and so are not similar. As sets the spectra of these matrices are both $\{0, 1\}$, but as multisets they are different: $\{0, 0, 1\}$, $\{0, 1, 1\}$.
It is true, however, that diagonal matrices with the same spectra as sets are necessarily similar if $n \leq 2$.