cross-posted from: https://lemmy.ml/post/1374138

I’m thinking about setting up my own (bare metal) Lemmy instance to play around with it, but it seems to require PostgreSQL. Everything else on my system uses MySQL, and I don’t really want to run 2 separate database services. I guess I would also be fine with using an SQLite file, but that’s not ideal.

Has anyone managed to set up a Lemmy instance with MySQL instead of PostgreSQL? Are you aware of any PostgreSQL to MySQL or SQLite compatibility layers?

  • terribleplan@lemmy.nrd.li
    link
    fedilink
    English
    arrow-up
    5
    ·
    1 year ago

    Lemmy is implemented in Rust using the Diesel ORM/Query Builder for persistence. I don’t know enough rust to comment specifically, but based on my knowledge of other ORMs and stuff it should be possible to support different database backends, but it would likely not “just work” without some effort on the part of the developers.

    One of the things that is being done for the next release is a bunch of pg optimization work, which to me makes it even less likely for it to work with minimal changes, as they are likely putting in some amount of postgres-specific code to achieve those gains.

    • v_krishna@lemmy.ml
      link
      fedilink
      English
      arrow-up
      1
      ·
      1 year ago

      Diesel supports mysql/Maria but meanwhile lemmy itself assumes it will be psql & I agree that changing that esp after 0.18 would be a silly idea. Changing it to support clickhouse or bigtable/c*/dynamo also a silly idea but maybe more worthwhile than mysql.

      • terribleplan@lemmy.nrd.li
        link
        fedilink
        English
        arrow-up
        1
        ·
        1 year ago

        I personally would love to see Cockroach support, as that is still a dialect of pg but often takes some work to get running right/well/at all.

  • MentalEdge@sopuli.xyz
    link
    fedilink
    English
    arrow-up
    3
    ·
    edit-2
    1 year ago

    They are not really interchangeable… They are intended for different use cases.

    And I’m pretty ready to bet that using any kind of bodged together compatibility-anything would be a lot more complex than just setting up postgres to begin with.

    I did for my matrix instance, and its bridges, it wasn’t complicated.

  • Slashzero@hakbox.social
    link
    fedilink
    English
    arrow-up
    1
    ·
    1 year ago

    That would not be an easy swap. There would be quite a bit of dev work to switch to MySQL.

    If it helps, I run MySQL and postgres in parallel on several servers without issue.

  • sinnerdotbin@lemmy.ca
    link
    fedilink
    English
    arrow-up
    1
    ·
    edit-2
    1 year ago

    Only PostgreSQL at the moment. I also don’t believe it currently supports SSL connection to Postgres so you’ll want to run it on the same machine or have a tunnel to your DB.

    There is zero chance you’ll get it running on anything else without significant code change.

    • @lemmy.ml
      link
      fedilink
      English
      arrow-up
      2
      ·
      1 year ago

      Diesel, the ORM package used by Lemmy, does have a MySQL backend, but all of the database migrations and performance considerations factored into the schema design are specifically written for PostgreSQL. It would be an absolutely massive undertaking to change this. It would be easier to create an entirely new threadiverse application from scratch.

  • suborbital@lemmy.ml
    link
    fedilink
    English
    arrow-up
    1
    ·
    1 year ago

    I know you stated wanting to run it on bare metal, but why not docker containers with a compose file? Would keep your system clean.

    • JuxtaposedJaguar@lemmy.mlOP
      link
      fedilink
      English
      arrow-up
      3
      ·
      1 year ago

      I don’t like Docker, personally. I’m not strongly opposed to using it, but I want to keep everything bare metal if I can.