The structures of (MgO)(3n) (2<or=n<or=10) clusters are studied using density functional theory (DFT). The starting structures are generated from empirical genetic algorithm simulations. The lowest-energy structures of (MgO)(3n) are then obtained from a number of structural isomers by using DFT optimization. It is found that when n<or=5 hexagonal tube is the most stable structure, and when n>or=6 (except 7) the rocksaltlike structure is favored, which is the same as that of the bulk. The n=7 is an interesting case, where the structure again is the hexagonal tube as the most stable structure. However, from the second order difference of the average atomization energy, we find that the n=7 case is thermodynamically unstable with respect to disproportionation to the smaller and larger clusters. The result may be the reason that it is not observed in the experiment. Therefore, we can conclude that the geometry transition really takes place at n=6. The rocksalt is the most stable structure for a large range of n numbers, from the (MgO)(3x6) cluster to bulk magnesium oxide. The result is different from Wilson's previous prediction because of the use of the ionic potential.