Water-rich planets can be found in our solar system (Uranus and Neptune) and extrasolar systems (some of the sub-Neptunes). While they have a critical ingredient for habitability, H2O, it is uncertain how such a dramatically different setting (very large amount of H2O) would impact the habitability. The models for water-rich planets so far have assumed little chemical interaction between H2O and minerals at high pressure, mainly due to the paucity of data on mineral-water reactions at high pressures and high temperatures. We have conducted a series of experiments on possible chemical reactions between key mineral phases of the rocky mantle and H2O at high pressures and high temperatures expected for the water-rock interfaces of 1-6 Earth-mass water-rich planets. We found that H2O solubility in silica (SiO2) increases dramatically with pressure, reaching 2:1 ratio between SiO2 and H2O in a single solid phase at pressures over 40 GPa. In contrast, a large amount of MgO can dissolve in dense liquid H2O at high pressure. In our experiments on (Mg,Fe)2SiO4 olivine in a H2O medium, MgO component disappears from X-ray diffraction patterns while silica rich minerals appeared at 20-50 GPa at high temperatures. The recovered samples show morphology consistent with dissolution of MgO in dense liquid H2O at the pressure range, explaining the X-ray observation. The solubility of MgO in dense liquid H2O appears to be similar to that of NaCl in H2O at room conditions. Our data indicate that the solubility of MgO decreases at pressures above 50 GPa. These experimental results suggest that the H2O layer of the Earth-sized water-rich planets (for example, TRAPPIST-1c and 1f if they are water rich) would contain a large amount of MgO. The H2O layer of larger water-rich planets (for example, GJ1214b) would have much lower concentration of MgO. The compositional gradient by MgO in H2O layer can impact thermal evolution of the water-rich planets. The rock-H2O interface in these planets would have silica rich composition because of chemical leaching of MgO by H2O. The low-density hydrous silica at the interface would form a thin layer which may control the geochemical interaction between the rocky layer and the H2O envelope of the water-rich planets.