# CLI命令

**URL:** https://heroiclabs.com/docs/zh/nakama/getting-started/commands/
**Summary:** 可用于运行和管理Nakama的可用命令行命令概览，包括升级和迁移。
**Keywords:** nakama cli, nakama cli options, nakama cli commands, nakama commands, cli, migrate, config, cli configuration
**Categories:** getting started, cli

---


# Nakama命令

Nakama的日常操作很简单，仅需最少干预。有几个可用的Nakama命令，仅需记住三个：

- [nakama](#nakama)
- [迁移](#migrate)
- [配置覆盖](#config)

## nakama

自行运行`nakama`命令将使用默认配置启动服务器。您可以使用命令行标志[覆盖默认配置](#config)值（和配置文件参数）。

## 迁移

Nakama二进制文件包含架构和升级现有数据库架构的方法。首次运行Nakama时，您需要设置与Nakama交互的数据库架构。同样，如果发布新的Nakama版本，您需要将数据架构迁移到新版本的对应位置。

| 命令          | 描述                                                                                                                                               |
|------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------|
| `migrate up`     | 创建数据库架构并将其更新至Nakama要求的最新版本。默认将架构按顺序更新至最新版本。 |
| `migrate down`   | 将数据库架构降级至要求的版本。默认情况下，每次降级一个架构变更。                                           |
| `migrate redo`   | 降级架构变更并重新应用变更。                                                                                                  |
| `migrate status` | 提供关于数据库当前应用的架构以及是否有未应用架构的信息。                                            |

| 标志              | 描述                                                                                                                                                                                           |
|--------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `database.address` | 需要连接的数据库节点。应该遵循`username:password@address:port/dbname`的形式（`postgres://`协议会自动追加到路径中）。默认为`root@localhost:26257`。 |
| `--limit`          | 运行`up`， `down`， 或`redo`时，要使用的迁移数。                                                                                                                              |

<!--
## doctor

Nakama ships with a built-in diagnostic tool which is particularly useful when you need support or otherwise are looking to diagnose an issue.

Running `nakama doctor` generates a report that details the server's configuration and environment. By default, the diagnostic tool looks for a Nakama node to connect to on the local machine, but this can be changed:

| Flags   | description                                                                              |
|---------|------------------------------------------------------------------------------------------|
| `host`  | The host running the Nakama instance you want to diagnose. Default value is `127.0.0.1`. |
| `limit` | Dashboard port used by nakama. Default value is 7351.                                    |
-->

## 配置

Nakama附带默认配置，可以通过使用[YML配置](../configuration/)文件或通过传递如下命令行标志覆盖默认配置：

```sh
nakama --config path/to/config.yml --database.address root@localhost:26257 --database.address root@machine-2:26257
```

命令行标志覆盖配置文件中设置的选项。配置文件覆盖默认配置选项。

在[配置文件](../configuration/#server-configuration)中查看配置标志的完整列表。

## 版本

使用`version`命令查看您的Nakama服务器实例的语义化版本。例如：

```sh
nakama --version
3.3.0+83fc6fbc
```

## 核查

`check`命令将解析任何命令行参数以查找运行时路径，服务器将在其中扫描Lua和Go库文件。

## 帮助

使用`help`命令显示所有可用的配置标志。也可以在[配置](../configuration/)页面查看配置标志。

```sh
nakama --help
```
