Update My SQL a Postgre

Good afternoon, I’ve tried migrating from MySQL to PostgreSQL in every way possible and have only encountered one problem after another.

  • I made a backup
  • I downloaded the migration tool
  • I tried using pgloader. However, the backup isn’t in the correct format, and the version of pgloader that installs isn’t the correct version because it has a bug. The steps I followed were:

sudo apt update
sudo apt install postgresql-16 postgresql-client-16
sudo -u postgres createuser -P mattermost
sudo -u postgres createdb -O mattermost mattermostdb
sudo apt install pgloader
sudo mysqldump --databases mattermostdb > mattermost.sql
nano migrate.load
LOAD DATABASE
FROM mysql://root:your_password@localhost/mattermostdb
INTO postgresql://mattermost:your_password@localhost/mattermostdb

WITH include drop, create tables, create indexes, reset sequences

SET work_mem to ‘16MB’,
maintenance_work_mem to ‘512 MB’,
search_path to 'publi
CAST type datetime to timestamptz drop default drop not null,
type timestamp to timestamptz drop default drop not null;
pgloader migrate.load

However, the database won’t connect due to password incompleteness. It’s always one error after another. And since I have no experience, I’m completely lost. I’ve also tried installing DBeaver to migrate, but it gives me an error. Can you help me?

hello rrmfar, I just completed a migration and update of mattermost successfully (from mariadb via mysql to postgres-14) . The one thing that sticks out and that I don’t remember seeing in guides is importing the mysqldump into directly, .. you are installing pgloader, but not using it?

you want my step by step to test?

1 Like

by ‘not using pgloader’ I mean the migration-assist part (I can see you use pgloader itself..)

./migration-assist postgres “postgres://mmuser:XXXXX@localhost:5432/mattermost?sslmode=disable” --run-migrations --mattermost-version=“10.8.0”
dnf install pgloader
./migration-assist pgloader --mysql=“mmuser:XXXXX@tcp(localhost:3306)/mattermost” --postgres=“postgres://mmuser:XXXXX@localhost:5432/mattermost?sslmode=disable” --remove-null-chars > migration.load

It was my understanding that this migration.load contains what migrates from mysql to postgres, and it’s much more than just importing the database

@Horned1
PostgreSQL 14 using port: 5433 for default. (not be as port: 5432 before)
Pls, check mattermost/config/config.json or /etc/postgresql/14/main/pg_hba.conf to matching listen port.

Si no te genero inconvenientes me gustaria tu ayuda para poder realizar el proceso. Gracias

The step by step I successfully used (most of this is in the docs: Automated PostgreSQL migration - Mattermost documentation )

Preparations
cd /tmp/
wget https://github.com/mattermost/migration-assist/releases/download/v0.5/migration-assist-Linux-x86_64.tar.gz
tar -xvf migration-assist-Linux-x86_64.tar.gz
dnf install pgloader
dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-9-x86_64/pgdg-redhat-repo-latest.noarch.rpm
dnf install postgresql14-server.x86_64 postgresql14.x86_64 postgresql14-contrib.x86_64 --nobest
/usr/pgsql-14/bin/postgresql-14-setup initdb
systemctl start postgresql-14
systemctl enable postgresql-14

systemctl stop mattermost

Start the migration

./migration-assist mysql “mmuser:XXX@tcp(localhost:3306)/mattermost” --fix-artifacts --fix-unicode --fix-varchar

in the guide there is a single command you are supposed to run, but after finfing this info on some forums I did all these commands separately and it solved my issues
[root@mattermost:/tmp]# sudo -u postgres psql
psql (14.19)
Type “help” for help.

postgres=# create database mattermost;
CREATE DATABASE
postgres=# CREATE USER mmuser WITH PASSWORD ‘XXX’;
CREATE ROLE
postgres=# GRANT ALL PRIVILEGES ON DATABASE mattermost to mmuser;
GRANT
postgres=# ALTER DATABASE mattermost OWNER TO mmuser;
ALTER DATABASE
postgres=# GRANT USAGE, CREATE ON SCHEMA PUBLIC TO mmuser;
GRANT
postgres=# \c mattermost;
You are now connected to database “mattermost” as user “postgres”.
mattermost=# SELECT current_database();
current_database

mattermost
(1 row)

mattermost=# ALTER SCHEMA public OWNER to mmuser;
ALTER SCHEMA
mattermost=# GRANT ALL ON SCHEMA public to mmuser;
GRANT
mattermost=# \q

the command below should have your own mattermost version of course
./migration-assist postgres “postgres://mmuser:XXX@localhost:5432/mattermost?sslmode=disable” --run-migrations --mattermost-version=“10.8.0”
./migration-assist pgloader --mysql=“mmuser:XXX@tcp(localhost:3306)/mattermost” --postgres=“postgres://mmuser:XXX@localhost:5432/mattermost?sslmode=disable” --remove-null-chars > migration.load

pgloader migration.load > migration.log

./migration-assist postgres post-migrate --create-indexes “postgres://mmuser:XXX@localhost:5432/mattermost?sslmode=disable”
./migration-assist pgloader boards --mysql=“mmuser:XXX@tcp(localhost:3306)/mattermost” --postgres=“postgres://mmuser:XXX@localhost:5432/mattermost?sslmode=disable” > boards.load
./migration-assist pgloader playbooks --mysql=“mmuser:XXX@tcp(localhost:3306)/mattermost” --postgres=“postgres://mmuser:XXX@localhost:5432/mattermost?sslmode=disable” > playbooks.load
./migration-assist pgloader calls --mysql=“mmuser:XXX@tcp(localhost:3306)/mattermost” --postgres=“postgres://mmuser:XXX@localhost:5432/mattermost?sslmode=disable” > calls.load

pgloader boards.load > boards_migration.log
pgloader playbooks.load > playbooks_migration.log
pgloader calls.load > calls_migration.log

set the sql connector to PSQL and change the unit-file to point to PostgreSQL as in the guide
vi /opt/mattermost/config/config.json
vi /etc/systemd/system/mattermost.service

Start and check for errors
systemctl start mattermost
journalctl -xeu mattermost.service

Then update as in docs ( Upgrade Mattermost Server - Mattermost documentation )
wget https://releases.mattermost.com/11.1.0/mattermost-11.1.0-linux-amd64.tar.gz
tar -xvf mattermost-11.1.0-linux-amd64.tar.gz mattermost/
systemctl stop mattermost
cd /opt/
cp -ra mattermost/ mattermost-back-$(date +‘%F-%H-%M’)/
sudo find mattermost/ mattermost/client/ -mindepth 1 -maxdepth 1 ! ( -type d ( -path mattermost/client -o -path mattermost/client/plugins -o -path mattermost/config -o -path mattermost/logs -o -path mattermost/plugins -o -path mattermost/data ) -prune ) | sort | sudo xargs rm -r

cp -an /tmp/mattermost/. mattermost/
chown -R mattermost:mattermost mattermost
setcap cap_net_bind_service=+ep ./mattermost/bin/mattermost

systemctl start mattermost
journalctl -xeu mattermost.service

Finally the forumposts I used at some point soving this issue for me
search path error

config that was depricated
https://support.mattermost.com/hc/en-us/articles/42915463550996-Mattermost-11-x-Upgrade-Error-Hidden-Archived-Channels

I sincerely appreciate the steps you provided; however, I am running everything on Ubuntu 24. I installed the tool via sudo apt install pgloader, but it installed a version that reports compatibility issues with MySQL. From that point onward, the repositories are misconfigured, and I inevitably encounter the same problems again.

cd /tmp/
wget https://github.com/mattermost/migration-assist/releases/download/v0.5/migration-assist-Linux-x86_64.tar.gz
tar -xvf migration-assist-Linux-x86_64.tar.gz
sudo apt install pgloader
sudo sh -c 'wget -O /etc/apt/trusted.gpg.d/pgdg.asc https://www.postgresql.org/media/keys/ACCC4CF8.asc'
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
sudo apt update
sudo apt install postgresql-14
sudo systemctl status postgresql  # Confirmed operational
systemctl stop mattermost
./migration-assist mysql "mmuser:rg22090801@tcp(localhost:3306)/mattermost" --fix-artifacts --fix-unicode --fix-varchar

The database creation and permission assignments executed flawlessly.

./migration-assist postgres post-migrate --create-indexes "postgres://mmuser:XXX@localhost:5432/mattermost?sslmode=disable"
./migration-assist pgloader boards --mysql="mmuser:XXX@tcp(localhost:3306)/mattermost" --postgres="postgres://mmuser:XXX@localhost:5432/mattermost?sslmode=disable" > boards.load
./migration-assist pgloader playbooks --mysql="mmuser:XXX@tcp(localhost:3306)/mattermost" --postgres="postgres://mmuser:XXX@localhost:5432/mattermost?sslmode=disable" > playbooks.load
./migration-assist pgloader calls --mysql="mmuser:XXX@tcp(localhost:3306)/mattermost" --postgres="postgres://mmuser:XXX@localhost:5432/mattermost?sslmode=disable" > calls.load

However, the following errors occurred during execution:

2025-11-25T18:21:31.032000Z LOG pgloader version "3.6.7~devel"
2025-11-25T18:21:31.317003Z LOG Migrating from #<MYSQL-CONNECTION mysql://mmuser@localhost:3306/mattermost {1006EA2D33}>
2025-11-25T18:21:31.317003Z LOG Migrating into #<PGSQL-CONNECTION pgsql://mmuser@localhost:5432/mattermost {1006EA2F23}>
2025-11-25T18:21:31.384004Z ERROR mysql: Failed to connect to mysql at "localhost" (port 3306) as user "mmuser": Condition QMYND:MYSQL-UNSUPPORTED-AUTHENTICATION >
2025-11-25T18:21:31.412004Z ERROR Database error 42P01: relation "mattermost.focalboard_blocks" does not exist
QUERY: UPDATE mattermost.focalboard_blocks SET "fields" = '{}'::json WHERE "fields"::text = '';

Thereafter, I was unable to proceed further—encountering persistent errors while attempting to restart the service. I even performed system updates and switched the database connection to PostgreSQL, yet the issues persisted.

That authentication error.. The problem is that currently pgloader doesn’t support caching_sha2_password authentication plugin, which is default for MySQL 8, whereas older MySQL versions use mysql_native_password plugin.

Also the error that the focalboards is missing is likely because of an error in migrating the ‘boards’ part, check the boards_migration.log for errors

If you are using MariaDB instead of Mysql (as I did) this is where my migration failed, some timestamps in focalboards has the wrong syntax on mariadb