Install CedarDB locally
This tutorial explains how to install and run the native CedarDB binary on your machine.
Get the binary
CedarDB is distributed as a standalone binary. It runs out of the box on any Linux distribution with glibc >= 2.27 (released in 2018).
To automatically download and decompress the appropriate version, run:
curl https://get.cedardb.com | bashCedarDB supports two modes of operation:
- Server mode: A PostgreSQL-compatible server for external clients.
- Interactive mode: A SQL shell for direct, manual interaction with the database.
Run as Server
The best way to set up CedarDB for production use is to start CedarDB in our PostgreSQL-compatible server mode.
Start in Server mode
By default, CedarDB runs in server mode:
./cedardb --createdb mydbThis starts the server and creates the mydb database directory if it doesn’t already exist.
Connect via domain socket
Initially, the server only accepts connections via local domain socket from the same OS user:
psql -h /tmp -U postgresYou can then create users and databases:
create user test with password '1234' superuser; -- Or use fine-grained privileges
create database test;Enable remote connections
To accept external connections (e.g., over TCP), run:
./cedardb mydb --address=::Then connect using a PostgreSQL compatible client, e.g.:
psql -h localhost -U test
psql -h cedardb.example.com -U testExplore command line options
To see all available flags and options, run:
./cedardb --helpRun interactively
Interactive mode launches a REPL-style SQL shell. You can use it to create, explore, and manipulate a database locally.
Create a new persistent database
To create and open a persistent database:
./cedardb --interactive --createdb mydbThis creates a new directory mydb in your current working directory where CedarDB stores its data files.
You can also specify an absolute or relative path:
./cedardb --interactive --createdb /opt/dbs/moviesOpen an existing database
If the database already exists, you can open it like this:
./cedardb --interactive mydbUsing the --createdb flag will create the database if it doesn’t exist.
If the database already exists, it will open the database instead.
Without the flag, CedarDB will only open an existing database and fail if none is found.
Create a temporary in-memory database
To launch an ephemeral, in-memory database:
./cedardb --interactive --inmemoryThis database exists only for the duration of the session and will be discarded upon exit.
Running SQL in the shell
Once in the SQL shell, you can run standard SQL:
create table example(i int);
insert into example values (42);The REPL supports:
- Common readline keyboard shortcuts (e.g., CTRL + R to search the history)
- Backslash commands:
\i schema_definition.sql -- Run commands from a file
\? -- View available commandsFor more details, see the SQL Reference.