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

如何查找并访问Hyperledger Fabric-CA默认数据库及查询指定表

Accessing Hyperledger Fabric CA's Default SQLite Database in First Network (Vagrant/Windows 7)

Got it, let's break down how to access the default Hyperledger Fabric CA database in your setup—since you're running the First Network, the CA uses SQLite by default (it's a lightweight, file-based database, no separate server required). Each CA node (like ca.org1.example.com or ca.org2.example.com) has its own independent database file. Here's step-by-step what you need to do:

Step 1: Connect to Your Vagrant Virtual Machine

Since your Fabric environment lives inside a Vagrant VM, start by accessing it from your Windows 7 host:

vagrant ssh

Step 2: Locate the Running CA Container

First, confirm which Fabric CA containers are active (they'll be running if you started the First Network with ./byfn.sh up):

docker ps | grep fabric-ca

You'll see output similar to this (example for Org1's CA):

abc123456789   hyperledger/fabric-ca:latest   "sh -c 'fabric-ca-serv…"   2 hours ago   Up 2 hours    0.0.0.0:7054->7054/tcp   ca.org1.example.com

Note down the container name (e.g., ca.org1.example.com) or ID (e.g., abc123456789).

Step 3: Enter the CA Container's Shell

Connect directly to the CA container's command line:

docker exec -it <CA_CONTAINER_NAME_OR_ID> bash

Step 4: Access the SQLite Database

The default database file is stored at /var/hyperledger/fabric-ca-server/fabric-ca-server.db. Use the built-in sqlite3 tool to connect to it:

sqlite3 /var/hyperledger/fabric-ca-server/fabric-ca-server.db

You'll see a sqlite> prompt, meaning you're successfully connected to the database.

Step 5: Query the Tables You Need

Now you can run SQL queries to pull data from the tables you're interested in:

  • To view all affiliations:
    SELECT * FROM affiliations;
    
  • To view all registered users:
    SELECT * FROM users;
    
  • To view all issued certificates:
    SELECT * FROM certificates;
    

Quick tips: Run .tables to list all available tables in the database, or .exit to quit the SQLite prompt when you're done.

Optional: Copy the Database File to Your Windows 7 Host

If you prefer to use a graphical tool (like SQLiteStudio) to browse the database, you can copy the file out of the container and into your Windows system:

  1. From the Vagrant VM shell, copy the DB file from the container to the VM's home directory:
    docker cp <CA_CONTAINER_NAME_OR_ID>:/var/hyperledger/fabric-ca-server/fabric-ca-server.db .
    
  2. Exit the Vagrant VM shell:
    exit
    
  3. Copy the file from the VM to your Windows 7 host (replace C:\Your\Target\Folder with your desired local path):
    vagrant scp default:/home/vagrant/fabric-ca-server.db C:\Your\Target\Folder
    
  4. Open the .db file with a SQLite GUI tool of your choice.

Important Notes

  • If your CA containers aren't running, start the First Network first by navigating to the first-network directory in the Vagrant VM and running ./byfn.sh up.
  • Each organization's CA has its own separate database—make sure you're accessing the correct CA container for the org you want to query.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.20 11:38:40