Here is my code. The expected results are not obtained.
Clear["Global`*"];
mD = {{a, b, c}, {d, e, f}, {g, h, i}};
mX = Array[X, {3, 3}];
sol = Solve[mD . mX == mX . mD, Flatten[mX]];
mX /. Flatten[sol] // MatrixForm
EDIT
The expected result is an n-order scalar matrix (a 3x3 scalar matrix in my example, p is an arbitrary symbolic variable):
$mX=\left(\begin{array}{lll}p & 0 & 0 \\ 0 & p & 0 \\ 0 & 0 & p\end{array}\right)$