1

postgresql学习记录2

 2 years ago
source link: https://www.hi-roy.com/posts/postgresql%E5%AD%A6%E4%B9%A0%E8%AE%B0%E5%BD%952/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

postgresql学习记录2

2014-08-06

想把mysql数据迁移到postgresql,推荐使用py-mysql2pgsql,使用pip安装即可。

安装完毕后执行py-mysql2pgsql后会在当前目录生成一个yaml文件,根据实际情况修改,例如:

# if a socket is specified we will use that
# if tcp is chosen you can use compression
mysql:
 hostname: localhost
 port: 3306
 socket: /var/lib/mysql/mysql.sock  #这里用find命令查找
 username: testuser
 password: '123456'  #记得引号
 database: testdb
 compress: false
destination:
 # if file is given, output goes to file, else postgres
 file:
 postgres:
  hostname: localhost
  port: 5432
  username: mytest
  password: '123456'
  database: mytest
# if tables is given, only the listed tables will be converted.  leave empty to convert all tables.
#only_tables:
#- table1
#- table2
# if exclude_tables is given, exclude the listed tables from the conversion.
#exclude_tables:
#- table3
#- table4
# if supress_data is true, only the schema definition will be exported/migrated, and not the data
supress_data: false
# if supress_ddl is true, only the data will be exported/imported, and not the schema
supress_ddl: false
# if force_truncate is true, forces a table truncate before table loading
force_truncate: false

至于下面的只迁移某些表、不迁移某些表、只要结构、只要数据等根据自己需要修改。

修改完毕后保存,再执行py-mysql2pgsql -v 开始自动迁移。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK