惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

F
Fortinet All Blogs
博客园 - 三生石上(FineUI控件)
小众软件
小众软件
人人都是产品经理
人人都是产品经理
V
Visual Studio Blog
Last Week in AI
Last Week in AI
V
V2EX
博客园_首页
IT之家
IT之家
Jina AI
Jina AI
博客园 - 叶小钗
The Cloudflare Blog
T
Tailwind CSS Blog
腾讯CDC
B
Blog
D
Docker
L
LangChain Blog
博客园 - 司徒正美
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
美团技术团队
Apple Machine Learning Research
Apple Machine Learning Research
爱范儿
爱范儿
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
GbyAI
GbyAI

博客园 - yahle

Performance Improvements in .NET 9 [翻译 by chatglm] Performance Improvements in .NET 8 & 7 & 6 -- File I/O【翻译】 Performance Improvements in .NET 8 & 7 & 6 -- String【翻译】 Performance Improvements in .NET 8 & 7 & 6 -- Thread【翻译】 Performance Improvements in .NET 8 -- Exceptions & Reflection & Primitives【翻译】 Performance Improvements in .NET 8 -- Native AOT & VM & GC & Mono【翻译】 Performance Improvements in .NET 8 -- JIT部分翻译 .net core 多线程下使用 Random 会出现bug 一个.net6开发的截图后ocr小工具 云服务器内容迁移 总结 立个铁矿石的flag,从7月初开始,铁矿石的库存,可能要进入累库存阶段了. 让你的 vs code 跑在云上,用手机浏览器就能写代码 - yahle ASP.NET Core 2 High Performance 目录和读书笔记 - yahle [转帖]无网络离线安装 vs2017 - yahle - 博客园 centos下 .net core 2.0 升级 到 2.1 遇到的一个小问题 .net core jwt 入门记录 GTX 750TI 使用 ffmpeg 时无法用 GPU HEVC(h.265) 进行加速 [翻译] 编写高性能 .NET 代码--第二章 GC -- 减少大对象堆的碎片,在某些情况下强制执行完整GC,按需压缩大对象堆,在GC前收到消息通知,使用弱引用缓存对象 [翻译] 编写高性能 .NET 代码--第二章 GC -- 将长生命周期对象和大对象池化
mysql迁移到pqsql笔记
yahle · 2023-07-03 · via 博客园 - yahle

在将MySQL迁移到PostgreSQL的过程中,遇到了一些问题,下面是一些简单的解决方案。

  • 使用命令,初始化数据库,并设置postgres的密码
    • bin\initdb -E UTF-8 -A md5 -U postgres -W -D data -- 如果只使用 bin\pg_ctl -D data init 则不会设置postgres的密码
    • 命令启动pqsql:bin\pg_ctl -D data -l postgresql.log start -- 启动后当前控制台不会退出,需要手动关闭(使用关闭脚本)
    • 关闭数据库:bin\pg_ctl -D data stop

为了允许本机以外的IP访问,需要修改监控模式。具体步骤如下:

  1. 修改 data\postgresql.conf 文件,将 listen_addresses 设置为 '*'
  2. 增加允许密码访问的地址,以允许特定账号使用密码登录。需要修改 data\pg_hba.conf 文件。在该文件中添加以下内容:
    host all all 192.168.1.0/24 md5
    其中,192.168.1.0/24 是允许访问的IP地址范围,md5 表示使用密码进行验证。

以下是使用 pqsql 时遇到的一些问题:

  1. 数据库名需要小写(虽然大写也能用),否则 HeidiSQL 工具无法使用。

  2. pqsql 自带 pgAdmin 4 工具,可以用来管理数据库

  3. ServiceStack 的 ORM,会自动把字段名和表名在执行时转为小写,所以在注册数据库连接时,对名字的处理策略,缓存默认的。
    ···
    var instance = PostgreSqlDialect.Instance;
    instance.NamingStrategy = new OrmLiteNamingStrategyBase();

    factory.RegisterConnection(databaseName, connStr, instance);
    ···

  4. ExecuteReader.Parse 会因为某些字段有特殊的序列化规则,而无法进行序列化
    解决办法,使用mysql分页脚本
    select * from {typeof(T).Name} limit batchSize offset skip -- 不好用,超过100w条记录后,会导致查询超时
    SELECT * FROM {typeof(T).Name} where id > {skip} and id <={skip + batchSize} -- 刚好默认id是自增的,可以使用这个脚本