| 104 | Using ogr2ogr, you can simply replicate a MySQL database into a Postgres database. The end result needs some massaging, but not much. |
| 105 | |
| 106 | Assuming you already created a Postgres database 'geonetwork' and a Postgres user 'postgressusername', you issue a command like |
| 107 | |
| 108 | {{{ |
| 109 | ogr2ogr -overwrite -update -f "PostgreSQL" PG:"host=localhost user=postgressusername dbname=geonetwork password=postgressuserpassword" MYSQL:"geonetworkdbname,host=localhost,user=mysqlusername,password=mysqluserpassword,port=3306" |
| 110 | }}} |
| 111 | |
| 112 | This creates the table structure in Postgres and copies the data into it. |
| 113 | |
| 114 | There are only 2 little tweaks necessary to make things work : |
| 115 | |
| 116 | * each table in Postgres gets a column {{{wkb_geometry}}} that was not there in your original, MySQL table |
| 117 | * Primary key column {{{id}}} gets called {{{ogc_fid}}} in Postgres |
| 118 | |
| 119 | The {{{wkb_geometry}}} columns can be fixed using this sql (thanks Thijs Brentjens) : |
| 120 | |
| 121 | {{{ |
| 122 | -- In pgsql: |
| 123 | -- create the SQL commands: |
| 124 | |
| 125 | select 'ALTER TABLE ' || table_name || ' drop column wkb_geometry;' from information_schema.tables where table_schema='public'; |
| 126 | |
| 127 | -- save the results to file and/or execute it directly: |
| 128 | ALTER TABLE isolanguages drop column wkb_geometry; |
| 129 | ALTER TABLE categories drop column wkb_geometry; |
| 130 | ALTER TABLE categoriesdes drop column wkb_geometry; |
| 131 | ALTER TABLE groups drop column wkb_geometry; |
| 132 | ALTER TABLE groupsdes drop column wkb_geometry; |
| 133 | ALTER TABLE languages drop column wkb_geometry; |
| 134 | ALTER TABLE isolanguagesdes drop column wkb_geometry; |
| 135 | ALTER TABLE monitoringrequests drop column wkb_geometry; |
| 136 | ALTER TABLE monitoringservices drop column wkb_geometry; |
| 137 | ALTER TABLE metadata drop column wkb_geometry; |
| 138 | ALTER TABLE metadatacateg drop column wkb_geometry; |
| 139 | ALTER TABLE metadatarating drop column wkb_geometry; |
| 140 | ALTER TABLE operationallowed drop column wkb_geometry; |
| 141 | ALTER TABLE monitoringlog drop column wkb_geometry; |
| 142 | ALTER TABLE monitoringstatsgroups drop column wkb_geometry; |
| 143 | ALTER TABLE operations drop column wkb_geometry; |
| 144 | ALTER TABLE operationsdes drop column wkb_geometry; |
| 145 | ALTER TABLE regions drop column wkb_geometry; |
| 146 | ALTER TABLE usergroups drop column wkb_geometry; |
| 147 | ALTER TABLE regionsdes drop column wkb_geometry; |
| 148 | ALTER TABLE relations drop column wkb_geometry; |
| 149 | ALTER TABLE settings drop column wkb_geometry; |
| 150 | ALTER TABLE users drop column wkb_geometry; |
| 151 | ALTER TABLE sources drop column wkb_geometry; |
| 152 | }}} |
| 153 | |
| 154 | |
| 155 | |
| 156 | |
| 157 | |