postgre数据迁移到mysql

来源:互联网 发布:程序员基本要求 编辑:程序博客网 时间:2024/04/29 13:32

方法一

1.导出整个数据库

导出整个数据库
#pg_dump -h localhost -U postgres(用户名) 数据库名(缺省时同用户名)   >/data/dum.sql
pg_dump -h localhost -U xxx yyy >D:\dum.sql
iYDP8292
注意: 1.以管理员权限打开命令行窗口;2.导出路径不存在错误

2.修改数据类型(看个人需要)
timestamp without time zone 改为 timestamp
numeric(10,2) 改为 float(10,2)
自增主键和时间的插入跟新自行修改

3.执行修改的sql语句


方法二

下载工具 Navicat Premium 可以同时连接mysql和postgre等其他数据库。通过这个工具导出再导入。


注意数据格式不兼容。

如: 

postgre的 boolean -> mysql的tinyint

postgre的 timestamp without time zone -> mysql的timestamp

1 0