Thursday, 24 June 2021

ArangoDB: Setup the database to experiment

In this post, I am going to show how to create a databse and add an user to it.

 

Step 1: Connect to aranogoDB server by executing the command arangosh in terminal.

$ arangosh 
Please specify a password: 

                                       _     
  __ _ _ __ __ _ _ __   __ _  ___  ___| |__  
 / _` | '__/ _` | '_ \ / _` |/ _ \/ __| '_ \ 
| (_| | | | (_| | | | | (_| | (_) \__ \ | | |
 \__,_|_|  \__,_|_| |_|\__, |\___/|___/_| |_|
                       |___/                 

arangosh (ArangoDB 3.7.11 [darwin] 64bit, using build , VPack 0.1.33, RocksDB 6.8.0, ICU 64.2, V8 7.9.317, OpenSSL 1.1.1k  25 Mar 2021)
Copyright (c) ArangoDB GmbH

Command-line history will be persisted when the shell is exited. You can use `--console.history false` to turn this off
Connected to ArangoDB 'http+tcp://127.0.0.1:8529, version: 3.7.11 [SINGLE, server], database: '_system', username: 'root'

Type 'tutorial' for a tutorial or 'help' to see common examples
127.0.0.1:8529@_system>

 

Step 2: Create a database by executing the below command.

db._createDatabase("example");

127.0.0.1:8529@_system> db._createDatabase("example");
true

 

Step 3: Create a user with name krishna and password tiger by executing bellow commands.

var users = require("@arangodb/users");

users.save("krishna", "tiger");

 

127.0.0.1:8529@_system> var users = require("@arangodb/users");

127.0.0.1:8529@_system> users.save("krishna", "tiger");
{ 
  "user" : "krishna", 
  "active" : true, 
  "extra" : { 
  }, 
  "code" : 201 
}


Step 4: Grant database access to the user Krishna by executing below command.

users.grantDatabase("krishna", "example");

127.0.0.1:8529@_system> users.grantDatabase("krishna", "example");


Step 5: Exit from the shell by executing the command exit.


127.0.0.1:8529@_system> exit

Uf wiederluege! 再见! Na shledanou! Auf Wiedersehen! Bye Bye! Adiau! ¡Hasta luego! Εις το επανιδείν! ءاقللا ىلإ
להתראות! Arrivederci! Tot ziens! Adjö! Au revoir! さようなら До свидания! Até B127.0.0.1:8529@_system> exit

Uf wiederluege! 再见! Na shledanou! Auf Wiedersehen! Bye Bye! Adiau! ¡Hasta luego! Εις το επανιδείν! ءاقللا ىلإ
להתראות! Arrivederci! Tot ziens! Adjö! Au revoir! さようなら До свидания! Até Breve! خداحافظ! Uz redzēšanos! შეხვედრამდე 안녕히 가세요! Sampai jumpa!
reve! خداحافظ! Uz redzēšanos! შეხვედრამდე 안녕히 가세요! Sampai jumpa!


Connect to example database with username Krishna

Open terminal and execute below command.

arangosh --server.username "krishna" --server.database example

$arangosh --server.username "krishna" --server.database example
Please specify a password: 

                                       _     
  __ _ _ __ __ _ _ __   __ _  ___  ___| |__  
 / _` | '__/ _` | '_ \ / _` |/ _ \/ __| '_ \ 
| (_| | | | (_| | | | | (_| | (_) \__ \ | | |
 \__,_|_|  \__,_|_| |_|\__, |\___/|___/_| |_|
                       |___/                 

arangosh (ArangoDB 3.7.11 [darwin] 64bit, using build , VPack 0.1.33, RocksDB 6.8.0, ICU 64.2, V8 7.9.317, OpenSSL 1.1.1k  25 Mar 2021)
Copyright (c) ArangoDB GmbH

Command-line history will be persisted when the shell is exited. You can use `--console.history false` to turn this off
Connected to ArangoDB 'http+tcp://127.0.0.1:8529, version: 3.7.11 [SINGLE, server], database: 'example', username: 'krishna'

Type 'tutorial' for a tutorial or 'help' to see common examples
127.0.0.1:8529@example> 


Connect to example database using web interface

Open the url ‘http://127.0.0.1:8529’ in browser.



Login with username krishna and password tiger.


 



Select the database example and click on the button ‘Select DB:example’.

 


What is the default database?

_system (All the system metadata store here)


Previous                                                    Next                                                    Home

No comments:

Post a Comment