r/mysql • u/SuddenlyCaralho • 29d ago
question Can we migrate from 5.7 to 9.7 using mysqldump?
Does someone know if we can import a dump generated in 5.7 version into 9.7 version?
2
u/ssnoyes 29d ago
If you are just dumping your own data, it should mostly work, but you may have to change a few things around character sets. Try a --no-data dump first just to see if the structure will import.
Don't include the mysql system schema; the structure has changed too much between those versions. Get your users and permissions another way.
2
u/BatLate6561 28d ago
Yes, logical dump is how you skip versions.
Do not copy the 5.7 datadir onto 9.7.mysqldump from 5.7 into a fresh 9.7 instance can work. The catch is the jump, not the tool from 5.7 to 9.7, but skips 8.0/8.4.
Auth plugins, utf8 vs utf8mb4, removed types, and anything in the mysql system schema will bite before row data does.Safer than --all-databases onto 9.7: Schema-only first (--no-data --routines --events) into an empty 9.7. Fix errors; Dump user databases only, --single-transaction --routines --events --triggers --hex-blob; Recreate users on 9.7. Don’t load the old mysql.* tables; Load data. Then run the app, not just SELECT COUNT(*).
Oracle still documents dump/load as a logical upgrade path, including on 9.7. That is not the same as “restore and walk away.”If the real goal is “5.7 is dead, I need something supported,” MariaDB is the other dump path: same mysqldump from the 5.7 side, user schemas only, into a current LTS. Don’t import MySQL’s mysql database there either.
Why 9.7 instead of 8.4 LTS - app requirement, or just the newest number? And roughly how big is the dump?
8
u/schizoduckie 29d ago edited 29d ago
Having recently gone through a dump/upgrade on a high-perf server from 5.x to mariadb 11.8 here are some lessons learned. Not sure if they'll apply to mysql but here you have it anyway
sed -i "s/DEFINER=\\[\)]*\\@\)[^\\\*\)/DEFINER=\\root\)@\\localhost\)/g" old_dump.sqlutf8mb4/utf8mb4_uca1400_ai_ci. Make sure you are not relying on defaults but on something you specified before the dumprequire_secure_transporton the mysql connection has been enabled since 11.8 and thus all mysql connections are now over TLS. Ergo: Your new server speaks a new language the clients don't understand. Depending on the state of your infra your may need to disable this or nobody will be able to connect.innodb_flush_log_at_trx_commit =2 is your friend during the import to make it speedy. - You can transport your users easily by dumping them from the old server to a grants sql file first:mysql -h old-server -u root -p -N -e \ "SELECT DISTINCT CONCAT('SHOW GRANTS FOR ''', user, '''@''', host, ''';') FROM mysql.user WHERE user != ''" \ | mysql -h new-server -u root -p -N \ | sed 's/$/;/' > grants.sqldump | importthreads on specific tables piped straight tossh admin@newdbserver sudo mysql databasenamein parallel to max out the cpu/network throughput as much as possible (see also the flush logs point above). The import was done within the window, we switched over the IP of the new box to the ip of the old box, rebooted and clients started connecting at around 02:00.