SurrealDB Docs Logo

Enter a search query

Back to home
SurrealDB

SurrealDB

SurrealQL via CLI

In this section, you will explore writing SurrealQL queries using the SurrealDB CLI. To get started, you will need to install the SurrealDB CLI on your local machine. You can do this by following the instructions in the installation section.

The CLI provides allows you to write, execute, and visualize SurrealQL queries in real-time.

Getting Started

After installing the SurrealDB CLI, you can start writing SurrealQL queries by running the surreal start command in your terminal. You can also add the --help flag to view the available options and commands.

To start a SurrealDB server, run the surreal start command, using the options below. This example serves the database at the default location (http://localhost:8000), with a username and password.

surreal start --endpoint http://localhost:8000 --user root --pass root

The server is actively running, and should be left alone until you want to stop hosting the SurrealDB server.

Terminal start

Running Queries

To run a SurrealQL query, In the new terminal, run the surreal sql command followed by the query you would like to execute. For example, to run a simple SELECT query, you can run the following command:

Start a SurrealDB Shell with local endpoint
surreal sql --endpoint http://localhost:8000 --ns test --db test
Start a SurrealDB Shell with memory endpoint
## Run query in memory surreal sql --endpoint memory --ns test --db test
Terminal SQL

Learn more

Learn more about the available commands and options in the SurrealDB CLI documentation.

On this page

© SurrealDB GitHub Discord Community Cloud Features Releases Install