You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用pgloader迁移Grafana SQLite数据到PostgreSQL遇文件打开错误

Grafana SQLite转PostgreSQL迁移:SQLite文件无法打开问题解决

从报错日志可以明确看到问题根源:pgloader解析后的SQLite路径被错误拼接成了/home/XXXXXXXXXXX/sqlite:/home/XXXXXXXXXXX/grafana.db,这是因为你在配置文件的from字段中使用了错误的格式。

问题原因

pgloader对SQLite数据源的格式要求有两种:

  1. URL格式:必须以sqlite:///开头(三个斜杠,协议后直接接绝对路径)
  2. 直接路径:仅填写文件的绝对路径,不需要前缀

你的配置中写了sqlite:/home/XXXXXXX/grafana.db(两个斜杠),pgloader错误地将sqlite:识别为路径的一部分,导致生成了无效的文件路径。

修正方案

将配置文件中的from字段改为以下两种正确格式之一:

格式1:URL规范写法

load database
  from sqlite:///home/XXXXXXX/grafana.db
  into postgresql://grafana:YYYYYY@99.199.199.199:5432/grafana_db
  with data only, reset sequences
  set work_mem to '16MB', maintenance_work_mem to '512 MB';

格式2:直接使用绝对路径

load database
  from /home/XXXXXXX/grafana.db
  into postgresql://grafana:YYYYYY@99.199.199.199:5432/grafana_db
  with data only, reset sequences
  set work_mem to '16MB', maintenance_work_mem to '512 MB';

额外验证步骤

  1. 执行ls -l /home/XXXXXXX/grafana.db确认文件存在且当前用户有读取权限
  2. 若服务器开启SELinux,可临时关闭或添加文件上下文规则(chcon -t mysqld_db_t /home/XXXXXXX/grafana.db)排除权限干扰

内容的提问来源于stack exchange,提问作者Anand

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.27 00:05:14