Ad Widget

Collapse

Migrate Mysql to postgres

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Wouaf
    Junior Member
    • Feb 2008
    • 9

    #1

    Migrate Mysql to postgres

    Hi,

    How can i do to migrate our Mysql zabbix database to postgresql?

    Thanks
  • xs-
    Senior Member
    Zabbix Certified Specialist
    • Dec 2007
    • 393

    #2
    its relatively easy

    prepare your postgresql database with the schema (not the data)

    make a script (perl, python, php, whatever) which sequentially selects all from a mysql table and dumps that into the correct postgresql table.
    (you might want to make it so its selects /inserts 10k rows a times to prevent memory issues).

    There are commercial products which can also do this, but they assume they have to migrate the schema as well. Better steer clear of those.

    Comment

    • teferi
      Member
      • Jul 2008
      • 93

      #3
      Originally posted by xs-
      its relatively easy

      prepare your postgresql database with the schema (not the data)

      make a script (perl, python, php, whatever) which sequentially selects all from a mysql table and dumps that into the correct postgresql table.
      (you might want to make it so its selects /inserts 10k rows a times to prevent memory issues).

      There are commercial products which can also do this, but they assume they have to migrate the schema as well. Better steer clear of those.
      Or just use mysqldump --compact -c -e -n -t --compatitable=postgresql

      Comment

      • xs-
        Senior Member
        Zabbix Certified Specialist
        • Dec 2007
        • 393

        #4
        well, i did a postgres to mysql migration once, so didnt look at mysqldump that closely. But the option is cool

        Comment

        • Alexei
          Founder, CEO
          Zabbix Certified Trainer
          Zabbix Certified SpecialistZabbix Certified Professional
          • Sep 2004
          • 5654

          #5
          Originally posted by teferi
          Or just use mysqldump --compact -c -e -n -t --compatitable=postgresql
          Thanks for the hint. I wasn't aware mysqldump supports PostgreSQL friendly output!
          Alexei Vladishev
          Creator of Zabbix, Product manager
          New York | Tokyo | Riga
          My Twitter

          Comment

          • teferi
            Member
            • Jul 2008
            • 93

            #6
            Originally posted by Alexei
            Thanks for the hint. I wasn't aware mysqldump supports PostgreSQL friendly output!
            It's not really that friendly, you'll still enounter warnings consearning string values, but most of them can be ignored.
            I also used
            Code:
            sed "s/\\\'/\'\'/g" zabbix_mysql.sql > zabbix_pg.sql
            but don't know really yet if it helps or makes it worser

            Comment

            • den_crane
              Senior Member
              • Feb 2006
              • 272

              #7
              Originally posted by teferi
              It's not really that friendly, you'll still enounter warnings
              edit postgresql.conf
              add option escape_string_warning = off
              and postgresql suppress warnings

              # mysqldump zabbix --compatible=postgresql --no-create-info --skip-quote-names --skip-add-locks > test.dmp

              # cat test.dmp|psql -U zabbixuser zabbix
              and I got 1 error ~~~ [ERROR: wrong byte encoding .... "UTF8": 0x89]
              table images field (blob) not loading

              Comment

              • jsosic
                Member
                • Apr 2008
                • 47

                #8
                Hi guys,

                I have done a recent migration of version 2.2.1 from MySQL to PostgreSQL. I've described the process on my blog, so instead of writing explanations again here, I'll just put a link:

                Three evil giants of the south are constantly on the attack With lies and fire from their mouths but we always send them back (Amon Amarth – Guardians of Asgaard) Sooner or later someone will…

                Comment

                • AnatolyUss
                  Junior Member
                  • Nov 2015
                  • 1

                  #9
                  Try <a href="https://github.com/AnatolyUss/FromMySqlToPostgreSql">FromMySqlToPostgreSql</a>.

                  This tool is feature-reach and easy to use. It maps data-types, migrates constraints, indexes, PKs and FKs exactly as they were in your MySQL db. Under the hood it uses PostgreSQL COPY, so data transfer is very fast.

                  Comment

                  Working...