# RedisGraph：图 'mygraph' 不存在。请先使用 GRAPH.CREATE。

- **ID:** `redis/redisgraph-module-error`
- **领域:** redis
- **类别:** module_error
- **错误码:** `ERR`
- **验证级别:** ai_generated
- **修复率:** 92%

## 根因

尝试对不存在的图键执行 GRAPH.QUERY，而未先调用 GRAPH.CREATE。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 7.2.0 | active | — | — |
| 7.4.0 | active | — | — |
| 8.0.0 | active | — | — |

## 解决方案

1. ```
   先创建图：GRAPH.CREATE mygraph。然后重试 GRAPH.QUERY mygraph 'MATCH (n) RETURN n'。
   ```
2. ```
   如果使用 RedisGraph v2.12+，启用自动创建：CONFIG SET graph.auto_create 1。然后 GRAPH.QUERY 将自动创建图。
   ```

## 无效尝试

- **** — Using GRAPH.QUERY with a non-existent graph name will auto-create it in some versions, but not in strict mode; this behavior is version-dependent and unreliable. (50% 失败率)
- **** — Renaming the graph key with RENAME will fail if the key doesn't exist; it doesn't solve the missing graph issue. (80% 失败率)
