Arangosh Examples

Connecting to a server

By default arangosh will try to connect to an ArangoDB server running onserver localhost on port 8529. It will use the username root and anempty password by default. Additionally it will connect to the default database(_system). All these defaults can be changed using the following command-line options:

  • —server.database <string>: name of the database to connect to
  • —server.endpoint <string>: endpoint to connect to
  • —server.username <string>: database username
  • —server.password <string>: password to use when connecting
  • —server.authentication <bool>: whether or not to use authenticationFor example, to connect to an ArangoDB server on IP 192.168.173.13 on port8530 with the user foo and using the database test, use:
  1. arangosh --server.endpoint tcp://192.168.173.13:8530 --server.username foo --server.database test --server.authentication true

arangosh will then display a password prompt and try to connect to the server after the password was entered.

The shell will print its own version number and if successfully connectedto a server the version number of the ArangoDB server.

If the server endpoint is configured for SSL then clients such as _arangosh_need to connect to it using an SSL socket as well. For example, use http+ssl://as schema in —server.endpoint for an SSL-secured HTTP connection.

The schema of an endpoint is comprised of a protocol and a socket in the formatprotocol+socket://. There are alternatives and shorthands for some combinations,ssl:// is equivalent to http+ssl:// and https:// for instance:

ProtocolSocketSchema
HTTPTCPhttp+tcp, http+srv, http, tcp
HTTPTCP with SSL/TLShttp+ssl, https, ssl
HTTPUnixhttp+unix, unix
VelocyStreamTCPvst+tcp, vst+srv, vst
VelocyStreamTCP with SSL/TLSvst+ssl, vsts
VelocyStreamUnixvst+unix

Using Arangosh

To change the current database after the connection has been made, youcan use the db._useDatabase() command in Arangosh:

  1. arangosh> db._createDatabase("myapp");
  2. arangosh> db._useDatabase("myapp");
  3. arangosh> db._useDatabase("_system");
  4. arangosh> db._dropDatabase("myapp");

Show execution results

  1. true
  2. true
  3. true
  4. true

Hide execution results

To get a list of available commands, Arangosh provides a help() function.Calling it will display helpful information.

arangosh also provides auto-completion. Additional information on available commands and methods is thus provided by typing the first few letters of avariable and then pressing the tab key. It is recommend to try this with enteringdb. (without pressing return) and then pressing tab.