postgresql跨服务器复制数据库
假设名为dbname数据库需要从A服务器拷贝到B服务器
接收服务器B
postgres用户
需先重置B服务器postgres系统用户的密码,使之与数据库用户postgres一致:
passwd -d postgres
sudo -u postgres passwd
如果不知道数据库用户postgres的密码, 在psql客户端使用命令ALTER USER postgres WITH PASSWORD '123456';重置.
创建数据库
B服务器需要先存在名为dbname的数据库才能接收.
CREATE DATABASE dbname
ssh相关
以postgres身份登录B后, 可在~/.ssh/authorized_keys 里面添加A服务器的公钥. 以免除输入密码的麻烦.
发送服务器A
切换postgres身份
su - postgres
pg_dump -C dbname | bzip2 | ssh postgres@B_host "bunzip2 | psql dbname"
参考
http://stackoverflow.com/questions/1237725/copying-postgresql-database-to-another-server
postgresql跨服务器复制数据库的更多相关文章
- mysql 跨服务器复制数据库
比较了下,还是采用ssh的方式最简单.比如传数据库test_db mysqldump --databases test_db| ssh 121.121.121.121 test_db
- SQLServer跨服务器访问数据库(openrowset/opendatasource/openquery)
SQLServer跨服务器访问数据库(openrowset/opendatasource/openquery) 1.启用Ad Hoc Distributed Queries 在使用openrowset ...
- SQL Server跨服务器操作数据库
今天给大家来分享一下跨服务器操作数据库,还是以SQL Server的管理工具(SSMS)为平台进行操作. 什么是跨服务器操作? 跨服务器操作就是可以在本地连接到远程服务器上的数据库,可以在对方的数据库 ...
- SQL跨服务器查询数据库
有时候一个项目需要用到两个数据库或多个数据库而且这些数据库在不同的服务器上时,就需要通过跨服务器查找数据 在A服务器的数据库a查询服务器B的数据库b 的bb表 假如服务器B的IP地址为:10.0.22 ...
- scp命令详解—跨服务器复制文件
scp在跨机器复制的时候为了提高数据的安全性,使用了ssh连接和加密方式,如果机器之间配置了ssh免密码登录,那在使用scp的时候密码都不用输入. 在服务器104.238.161.75上操作,将服务器 ...
- SQL Server 跨服务器 不同数据库之间复制表的数据
不同数据库之间复制表的数据的方法: 当表目标表存在时: insert into 目的数据库..表 select * from 源数据库..表 当目标表不存在时: select * into 目的数据库 ...
- postgresql使用pg_dump和pg_restore 实现跨服务器的数据库迁移或备份
因为业务需求,需要将服务器上的postgre多个数据库的数据整个库得迁移到另一个postgre数据库上. 一般表较少时,会使用postgre 的copy to 和 copy from 命令就能完成表的 ...
- SqlServer 跨网段跨服务器复制
注意:被同步的表必须有主键,否则无法同步.对数据库进行操作时需要登录服务器,在服务器本地进行操作,远程对数据库进行操作不能完成所有的步骤 准备工作: 1.将发布数据库完整备份到订阅服务器上,并在订阅服 ...
- [转]SQLServer跨服务器访问数据库(openrowset/opendatasource/openquery)
正 文: 1.启用Ad Hoc Distributed Queries 在使用openrowset/opendatasource前搜先要启用Ad Hoc Distributed Queries服务,因 ...
随机推荐
- find()用法
>>> str = '编程改变世界'>>> str.find('编')0>>> str.find('程')1>>> str.fi ...
- 关于sql多表去重问题
很多人新手对于数据库distinct 的用法有误解接下来我们看一段代码: 数据表:table id name 1 a 2 b 3 c 4 c 5 b 我们使用distinc ...
- [LeetCode] Array Partition I 数组分割之一
Given an array of 2n integers, your task is to group these integers into n pairs of integer, say (a1 ...
- [LeetCode] Minesweeper 扫雷游戏
Let's play the minesweeper game (Wikipedia, online game)! You are given a 2D char matrix representin ...
- [LeetCode] Most Frequent Subtree Sum 出现频率最高的子树和
Given the root of a tree, you are asked to find the most frequent subtree sum. The subtree sum of a ...
- PKUWC 2018 滚粗记
day0 上午居然考了一场考试,大爆炸,攒了一波RP,下午也没有心思去落实题目,而是一心去搞颓废,到了晚上看时间还早,于是就看了一波上午考试的Solution,懵逼.jpg day1 上午考数学,前一 ...
- 线性规划与网络流24题●09方格取数问题&13星际转移问题
●(做codevs1908时,发现测试数据也涵盖了1907,想要一并做了,但因为“技术”不佳,搞了一上午) ●09方格取数问题(codevs1907 方格取数3) 想了半天,也没成功建好图: 无奈下 ...
- ●BZOJ 4289 PA2012 Tax
●赘述题目 算了,题目没有重复的必要. 注意理解:对答案造成贡献的是每个点,就是了. 举个栗子: 对于如下数据: 2 1 1 2 1 答案是 2: ●题解 方法:建图(难点)+最短路. 先来几个链接: ...
- 2015 多校联赛 ——HDU5305(搜索)
Friends Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Su ...
- Codeforces Round #402 (Div. 1)
A题卡壳了,往离线倒着加那方面想了会儿,后来才发现方向错了,二十多分钟才过掉,过了B后做D,想法好像有点问题,最后只过两题,掉分了,差一点回紫. AC:AB Rank:173 Rating:2227- ...