Running the OrientDB Console

There are various methods you can use to connect to your database server and the individual databases, once the server is running, such as the Network Binary and HTTP/REST protocols. In addition to these, OrientDB provides a command-line interface for connecting to and working with the database server.

Starting the OrientDB Console

In the OrientDB installation directory, (that is, $ORIENTDB_HOME, where you installed the database), under bin, there is a file called console.sh on Unix-based systems and on Windows console.bat.

To launch the OrientDB console, run the following command after you start the database server:

  1. $ cd $ORIENTDB_HOME/bin
  2. $ ./console.sh
  3.  
  4. OrientDB console v.X.X.X (build 0) www.orientdb.com
  5. Type 'HELP' to display all the commands supported.
  6. Installing extensions for GREMLIN language v.X.X.X
  7.  
  8. orientdb>

The OrientDB console is now running. From this prompt you can connect to and manage any remote or local databases available to you.

Using the HELP Command

In the event that you are unfamiliar with OrientDB and the available commands, or if you need help at any time, you can use the HELP command, or type ? into the console prompt.

  1. orientdb> HELP
  2.  
  3. AVAILABLE COMMANDS:
  4. * alter class <command-text> Alter a class in the database schema
  5. * alter cluster <command-text> Alter class in the database schema
  6. ... ...
  7. * help Print this help
  8. * exit Close the console

For each console command available to you, HELP documents its basic use and what it does. If you know the particular command and need details on its use, you can provide arguments to HELP for further clarification.

  1. orientdb> HELP SELECT
  2.  
  3. COMMAND: SELECT
  4. - Execute a query against the database and display the results.
  5. SYNTAX: select <query-text>
  6. WHERE:
  7. - <query-text>: The query to execute

Connecting to Server Instances

There are some console commands, such as LIST DATABASES or CREATE DATABASE, which you can run while only connected to the server instance. For other commands, however, you must also connect to a database, before they run without error.

Before you can connect to a fresh server instance and fully control it, you need to know the root password for the database. The root password is located in the configuration file at config/orientdb-server-config.xml. You can find it by searching for the <users> element. If you want to change it, edit the configuration file and restart the server.

  1. ...
  2. <users>
  3. <user resources="*"
  4. password="my_root_password"
  5. name="root"/>
  6. <user resources="connect,server.listDatabases,server.dblist"
  7. password="my_guest_password"
  8. name="guest"/>
  9. </users>
  10. ...

With the required credentials, you can connect to the database server instance on your system, or establish a remote connection to one running on a different machine.

  1. orientdb> CONNECT remote:localhost root my_root_password
  2.  
  3. Connecting to remote Server instance [remote:localhost] with user 'root'...OK

Once you have established a connection to the database server, you can begin to execute commands on that server, such as LIST DATABASES and CREATE DATABASE.

  1. orientdb> LIST DATABASES
  2.  
  3. Found 1 databases:
  4. * GratefulDeadConcerts (plocal)

To connect to this database or to a different one, use the CONNECT command from the console and specify the server URL, username, and password. By default, each database has an admin user with a password of admin.

Warning: Always change the default password on production databases.

The above LIST DATABASES command shows a GratefulDeadConcerts installed on the local server. To connect to this database, run the following command:

  1. orientdb> CONNECT remote:localhost/GratefulDeadConcerts admin admin
  2.  
  3. Connecting to database [remote:localhost/GratefulDeadConcerts] with user 'admin'...OK

The CONNECT command takes a specific syntax for its URL. That is, remote:localhost/GratefulDeadConcerts in the example. It has three parts:

  • Protocol: The first part of the database address is the protocol the console should use in the connection. In the example, this is remote, indicating that it should use the TCP/IP protocol.

  • Address: The second part of the database address is hostname or IP address of the database server that you want the console to connect to. In the example, this is localhost, since the connection is made to a server instance running on the local file system.

  • Database: The third part of the address is the name of the database that you want to use. In the case of the example, this is GratefulDeadConcerts.

For more detailed information about the commands, see Console Commands.

Note: The OrientDB distribution comes with the bundled database GratefulDeadConcerts which represents the Graph of the Grateful Dead’s concerts. This database can be used by anyone to start exploring the features and characteristics of OrientDB.