Search code examples
windowssurrealdb

Unable to connect SurrealDB with a Sample Rust Application


I am trying to create a simple ToDo App using rust, Axum, and SurrealDB as a DB. For SurrealDB, I have installed it using

iwr https://windows.surrealdb.com -useb | iex

then, I am trying to create the below table

DEFINE TABLE todo SCHEMAFULL;
DEFINE FIELD title ON todo TYPE string;
DEFINE FIELD content ON todo TYPE string;
DEFINE FIELD completed ON todo TYPE bool;
DEFINE FIELD createdAt ON todo TYPE datetime;
DEFINE FIELD updatedAt ON todo TYPE datetime;

So, I am using the below command

surreal sql --conn http://localhost:8000 --user root --pass root`, but it is giving me an error

There was a problem with the database: There was an error processing a remote HTTP request: HTTP status client error (401 Unauthorized) for url (http://localhost:8000/signin).

How to solve this issue ?


Solution

  • do you have the database running first with surreal start? If you begin with surreal start --user root --password root to start the database then that should create the root user, after which your surreal sql command should work.