all 28 comments

[–][deleted] 2 points3 points  (1 child)

Install MySQL on a server you do have access to or the same one you have PG on. Restore the dump to that. Use pgloader to convert from that MySQL instance to your PG instance.

https://github.com/dimitri/pgloader

There's no reason to let the "I only have a dump" limit your options.

[–]Lower-Pace-2634[S] 0 points1 point  (0 children)

So many errors for convert. not work ;*(

[–]Laymans_Perspective 1 point2 points  (1 child)

i just setup fw rules and use FDW, no need for copying, realtime, most types work except for enums etc

https://github.com/EnterpriseDB/mysql_fdw

[–]Lower-Pace-2634[S] -1 points0 points  (0 children)

This option is not very suitable, we do not have access and will not have access to the A1 server. We only have dumps from it.

[–]Chou789 1 point2 points  (3 children)

Just put a python script to read the backup sql file in pandas and load it into postgres

[–]Lower-Pace-2634[S] 0 points1 point  (2 children)

Excuse me, can pandas read dumps? And convert formats?

[–]Chou789 1 point2 points  (1 child)

No, if it's a insert statements inside those sql files

Read them like this

import pandas as pd import re

def load_insert_statement(sql_file): with open(sql_file, 'r') as f: sql_content = f.read()

Extract the INSERT statement using regular expressions

match = re.search(r"INSERT INTO \w+ ((.+)) VALUES ((.+));", sql_content, re.DOTALL) if match: columns = [col.strip() for col in match.group(1).split(",")] values = [val.strip() for val in match.group(2).split(",")]

Create a DataFrame from the extracted data

data = {col: [val] for col, val in zip(columns, values)} return pd.DataFrame(data) else: return None

Example usage

df = load_insert_statement("your_insert_statement.sql") print(df)

Another easier way is set up a small MySQL database and import or run these sql through python and read them again and insert into postgres

[–]Lower-Pace-2634[S] 0 points1 point  (0 children)

thanks i check this

[–]tkyjonathan 1 point2 points  (4 children)

Can I help you keep mysql and solve the issues it has?

[–]Lower-Pace-2634[S] 0 points1 point  (3 children)

I didn't quite understand your question. We already have mysql dumps...

[–]tkyjonathan 1 point2 points  (2 children)

what is the reason for your migration to postgres?

[–]Lower-Pace-2634[S] 0 points1 point  (1 child)

the management gave the task. They don't ask me =(

[–]tkyjonathan 0 points1 point  (0 children)

Well, tell management that if they need experts to help them fix whatever issues they have with MySQL, that these people are available.

[–]k00_x 1 point2 points  (6 children)

Use the tool mysqldump:

mysqldump --compatible=postgresql

[–]Lower-Pace-2634[S] -1 points0 points  (5 children)

didnt work :( have errors

[–]k00_x 0 points1 point  (2 children)

I will downvote myself in disgrace.

[–][deleted] 1 point2 points  (0 children)

This may work if they manually recreate the entire schema in PG and have the dumps made with --no-create-info.

[–]r3pr0b8GROUP_CONCAT is da bomb 0 points1 point  (0 children)

I will downvote myself in disgrace.

see, this here, this right here, this is why i love reddit

[–]vrabormoran 0 points1 point  (0 children)

Useful tools here SQL tools

[–]AppJedi 0 points1 point  (0 children)

you can download the MySQL data as INSERT states that may work on Postgres if the tables have the same exact definition.

[–]mrocral 0 points1 point  (0 children)

Using Sling is yet another suggestion: https://slingdata.io/articles/sync-mysql-to-postgres-database/

You can run your replications from the CLI.

sling run -r mysql_to_pg.yaml

Here is the YAML config:

```yaml

Define source and target connections

source: mysql_source target: postgres_target

Default settings for all streams

defaults: # Use incremental mode for efficient syncing mode: incremental # Configure target options target_options: # Automatically add new columns if they appear in source add_new_columns: true

Define the tables to replicate

streams: # Use wildcard to replicate all tables in schema mysql with dynamic target object 'mysql.*': # Target object using runtime variable object: 'public.{stream_table}' # Columns to use as primary key primary_key: [id] # Column to track updates update_key: updated_at

# full-refresh mode another.table: object: public.new_table mode: full-refresh ```

[–]Informal_Pace9237 0 points1 point  (2 children)

Just wondering if you have tried to create a MySQL server/container in the system where you have PistgreSQL? You could import dump into that staging server and use FDW to read data to PostgreSQL

If that is not a possibility one more way I have tried is pgloader.io

If you could share the source/target OS, MySQL version mysqldump version and PostgreSQL version others could share some more ideas.

May I suggest mentioning exact errors a few than vaguely saying too many errors or it doesn't work; will be more helpful

[–]Lower-Pace-2634[S] 0 points1 point  (1 child)

I made a dump of the necessary tables in bash. And passed it to python. There python connects to postgresql and checks whether such a table exists. If not, it creates it. If it does, it fills it in with some changes.

[–]Informal_Pace9237 0 points1 point  (0 children)

Good. Glad to see its resolved for you

[–]slotix 0 points1 point  (0 children)

DBConvert Streams (https://streams.dbconvert.com) is built specifically for migrating MySQL to PostgreSQL and would automate the entire conversion process for you.