Guest User

Untitled

a guest
Feb 22nd, 2019
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. #
  2. # MIGRATE MySQL4 DATABASES TO MySQL5 - Steps for dumping and converting
  3. #
  4. # Uses mysqldump and patches output to be compatible with MySQL 5.5+ (? - no sure
  5. # at which specific release of MySQL 5 the old style syntax support ended).
  6. #
  7. # Conversion is most likely incomplete. It does some essential converting where
  8. # I regularly experienced problems during migration.
  9. #
  10. # Use on own risk, always try with test databases first. No warranty at all!
  11. #
  12. # Feel free to ask, improve, contribute!
  13. #
  14. # (c) 2013 Matthias Lienau
  15.  
  16. # 1. Use mysqldump do dump schema of the MySQL 4 database you want to migrate.
  17. # I recommend doing this using two files: One for the schema and one for the data dump.
  18. # Assumes your existing old database name is "mydb".
  19. # (Never forget to provide --username=[user] and --password=[pass])
  20. $ mysqldump [--username=user --password=pass] -d mydb > mydb-schema.sql
  21. $ mysqldump [--username=user --password=pass] -t mydb > mydb-data.sql
  22.  
  23. # 3. Replace old style comments ("--") with new style comments ("#") from both files
  24. $ sed -r -i -e 's/^--(.*)$/#\1/' mydb-schema.sql
  25. $ sed -r -i -e 's/^--(.*)$/#\1/' mydb-data.sql
  26.  
  27. # 2. Replace old storage type declaration keyword from "TYPE" to "ENGINE" (e.g. "TYPE=MyISAM" => "ENGINE=MyISAM")
  28. $ sed -i -e 's/) TYPE=/) ENGINE=/' mydb-schema.sql
  29.  
  30. # 4. Replace simplified timestamp field definition with full 5.x syntax
  31. # Maybe here are more cases with other on update values - didn't check this!
  32. $ sed -i -e 's/timestamp(14) NOT NULL,$/timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,/' mydb-schema.sql
  33.  
  34. # 5. Go and import the modified schema and data files to your new and fresh MySQL 5 database
  35. # Assumes your new database is created and named "mynewdb".
  36. # (Again don't forget to provide --username/--password)
  37. $ mysql mynewdb < mydb-schema.sql
  38. $ mysql mynewdb < mydb-data.sql
Add Comment
Please, Sign In to add comment