Quick Start - SurrealTools/Documentation GitHub Wiki

Start Server

surreal start --log trace --user root --pass root file:/Users/nationtech/SurrealDB
surreal start --log debug --user root --pass root file:C:/Users/path/to/db

Start Server with FoundationDb

Download https://github.com/apple/foundationdb/releases/tag/7.2.9

/// path must be an empty string or a local file path to a FDB cluster file.
/// An empty string results in using the default cluster file placed
/// at a system-dependent location defined by FDB.
/// See https://apple.github.io/foundationdb/administration.html#default-cluster-file for more information on that.

surrealdb start fdb://your-foundationdb-address

StartSurrealDB with SSl/TLS

SurrealDB doesn't run with SSL/TLS unless you explicitly start it with a certificate and a key. You can find instructions on how to create a self-signed certificate and private key here: stackoverflow.com/questions/10175812/how-to-generate-a-self-signed-ssl-certificate-using-openssl

If you want your server accessible from the internet with no security warnings, then you would need to use a certificate generated by a recognised organisation (Google, Amazon, Comodo, Digicert, Thawte...).

You need to start surreal with the following options:

surreal start --web-crt my_certificate.crt --web-key my_certificate.key

Docker

docker run --rm -p 8000:8000 -v /tmp:/tmp surrealdb/surrealdb:latest start --user root --pass root file:/tmp/my_db
docker run --rm surrealdb/surrealdb:latest sql --conn http://localhost:8000 --user root --pass root --ns test --db test

docker run --pull --rm surrealdb/surrealdb:latest help

Setting Db Engine

/// Connect to a database engine /// /// ```js /// const db = new Surreal(); /// /// // Connect to a WebSocket engine /// await db.connect('ws://localhost:8000'); /// /// // Connect to an HTTP engine /// await db.connect('http://localhost:8000'); /// /// // Connect to a memory engine /// await db.connect('mem://'); /// /// // Connect to an IndxDB engine /// await db.connect('indxdb://MyDatabase'); /// /// // Connect to a strict memory engine /// await db.connect('memory', { strict: true }); /// /// // Limit number of concurrent connections /// await db.connect('ws://localhost:8000', { capacity: 100000 });

enable one of the file storage features (kv-rocksdb, kv-speedb [nightly]) and use them instead of ws address with a local path (ie. rocksdb://some-folder/locally)

Start as a Service

In ubuntu you could try to create a systemd init script like follows: sudo touch /lib/systemd/system/surrealdb.service

then edit that file as root:

[Unit]
Description=SurrealDB
After=network.target

[Service]
Type=notify
ExecStart=/path/to/surrealdb
TimeoutStartSec=3600
KillMode=mixed
Restart=always
RestartSec=10
WorkingDirectory=/path/to/
User=surreal
Group=surreal
LimitNOFILE=49152

[Install]
WantedBy=multi-user.target

note to change /path/to and the User and Group of initializing user note that this is just a very barebones service descriptor for a systemd script - you might want to ExecStart a script that pulls in your env setups etc - it's not usable as itself, as the binary needs options etc