Changes

Jump to navigation Jump to search
2,340 bytes removed ,  15:00, 25 July 2022
no edit summary
This step by step tutorial shows article belongs to the [[Getting Started]] Guide. It tells you how to run BaseX in client-server mode from a terminal. You can copy & paste the commands to get it running on your machine.After you finished this tutorial, you will be familiar with the basic BaseX commandscommand-line.
==Startup==
see the [[Startup Overview]].==Server==
===Starting the Server===*Navigate to the location of basex.jar (<code>> cd /basex</code>).*You can either start the server in interaction mode if you add the -i flag. This allows you to further interact with {{Announce|With Version 10, the server during runtime (add databases or users, ...)default admin password has been removed.}}
<code>:> java -cp BaseX.jar org.basex.BaseXServer -i</code> :Or the The database server can be started alternatively without the -i flag. Notehandles concurrent [[Transaction_Management|read and write transactions]], that you have to restart the server to execute further commands from this shell.<code>: > java -cp BaseX.jar org.basex.BaseXServer</code> *A default admin [[User Management|manages user is created (you can change the password with the permissions]] and [[CommandsLogging|PASSWORDlogs user interactions]] command)::Username: admin:Password: admin *Once the server has successfully . It can be started you see the following linesas follows:<pre>BaseXServer [Server]Server was started.</pre>
===Starting * Run one of the {{Code|basexserver}} or {{Code|basexserver.bat}} scripts. Use {{Code|basexserverstop}} or {{Code|basexserverstop.bat}} to gracefully shut down the Client===server.*Open a new terminal windowIf you have installed BaseX on ''Windows'', make sure you are in click on the right directory '''BaseX HTTP Server (/basexStart).*Execute ''' icon, which will start both the following to start HTTP Server used for [[#Web Application|Web Applications]] and the client:<code>:> java -cp database server. With '''BaseXHTTP Server (Stop)''', you can shut down the server process.jar org.basex.BaseXClient</code>
*If Unless you haven't changed the have already chosen an admin password with yet (e.g., via the serverWindows installer or a previous installation), you can login as default user (admin/admin).do so by invoking the {{Command|PASSWORD}} command on your terminal:
==First Operations==<pre>basexserver -c PASSWORDTo get familiar with BaseX we suggest to execute the following basic operations. ===Creating a database===* To create a database you need an XML document, e.g. [http://www.w3.org/XML/Binary/2005/03/test-data/Over100/factbook.xml factbook.xmlServer].* Save this document to the /basex directory.* On the client terminal run: <code>: > create db factbook factbook.xml</code> : ''factbook'' - is the name of the database <br/>Server was started (port: ''factbook1984).xml'' - is the xml file, which is used to create the database<br/>  If everything works you see the following linesPassword:<pre>Database 'factbook' created in 1950.83 ms._
</pre>
;Where is the database stored?
Databases are stored in the BaseXData directory which is located in your home folder. Depending on your operating system the location of your home folder varies. For example, on a mac it's /Users/John, if your name is John.
===Executing a query===The [[CommandsBy default, the server listens to the port {{Code|xquery]] command lets you run a query1984}}.* For example, this query returns Pressing {{Code|Ctrl+c}} will close all country nodes in connections and databases and gracefully shut down the currently opened databaseserver process.<code>: > xquery //country</code>
* You Various [[Command-Line_Options#Server|command-line options]] are available to simplify batch processing. The [[Start_Scripts|start script]] can also run queries in files:<code>: > run /Users/John/querybe adjusted for individual purposes (e.g. if the default memory limit is too restrictive).xq</code>
==Client=Creating a new database===Now we will create another database. You can find the example document here: [http://phobos101.inf.uni-konstanz.de/basex/demo].
* Create the new database, named 'xmark'.<code>Database clients are started similarly: > create db xmark xmark.xml</code>
* Set Run one of the new database xmark as {{Code|basexclient}} or {{Code|basexclient.bat}} scripts.* Execute the contextfollowing command:{{Code|java -cp BaseX.jar org.basex.BaseXClient}}<code>: > open xmark</code>* If you have installed BaseX on ''Windows'', click on the '''BaseX Client''' icon.
* Now At startup, you can easily execute queries on need to enter your new database:<code>: > xquery //people/person/name</code>credentials.
===Switching For further details, have a look at the database===* You can explicitly query the factbook database with the doc()[[Command-Line_Options#Client|command-funtion, no matter what line options]] and the current context is[[Start_Scripts|start script]].<code>: > xquery doc("factbook")//country</code>
* Otherwise, to set factbook as the current context, execute the following:<code>: > open factbook</code>=Introduction=
* To list The BaseX command-line client provides similar features to the current context[[Command-Line Client|standalone client]]. The major difference is that all commands will be executed by the BaseX server instance. As a consequence, type:<code>: > show databases<paths/code> That yields URIs to resources need to be resolvable by the server (file contents will not be transfered to the following lines:server).
Username and password can also be specified as command-line option. To evaluate commands without entering the console mode, you can use the <code>-c</code> option on the command line:
<pre>
1 opened database(s):basexclient - factbook (1x)V -Uadmin -P... -c "CREATE DB input <example/pre>; XQUERY /"
Database 'input' created in 13.85 ms.
<example/>
Query:
/
===Close or delete a database===Parsing: 0.18 msIf you want to close the opened database, simply typeCompiling:0.04 msEvaluating:<code>0.12 ms> closePrinting: 0.07 ms</code>Total Time: 0.41 ms
If you want to delete the xmark database, useHit(s):1 ItemUpdated:<code>0 Items> drop db xmarkPrinted: 10 BytesRead Locking: local [input]</code>Write Locking: none
===Create a collection==='''What is a collection?'''With BaseX you can group documents into one logical collection.A collection is a database that contains two or more documents.You can put any type of XML documents into the collection, regardlessof their structure. Now we will add the xmark.xml document to the factbook database,and thus create a collection. The collection will keep the name factbook. First make sure factbook is opened::<code>> open factbook</code> Now add the xmark.xml document: :<code>> add xmark.xml</code> ===Delete a document from a collection===Deleting a document from a collection is very easy, just type::<code>> delete xmark.xml</code> N.B. The collection has to be the context i.e. the database whichcontains the document has to be openedQuery "user" executed in 0===Delete a collection===Deleting a collection is the same as deleting a database41 ms.If you want to delete the collection factbook, type::<code>> drop factbook</code> ===Getting information about the server===To see all databases on the server, type::<code>> list</code> To see which database is currently opened, type::<code>> show databases</code> To see the general information of the opened database, type::<code>> info</code> To see the users in BaseX, type::<code>> show users</code> ===Backup and Restore===To backup your database, type::<code>> backup factbook</codepre>
To restore your database, type::<code>> restore factbook</code>=Language Bindings=
'''Where is If you want to communicate with the backup-file stored?'''database server programmatically, we provide clients for various [[Clients|programming languages]].
The backup-file is stored in the BaseXData directory, which is in your home directory.The file is named factbook-timestamp.zip (db_name-timestamp.zip).To restore the database the file with the newest timestamp is taken.=Changelog=
==See also ==;Version 10.0[[BaseX Standalone]], [[BaseX GUI]], [[Getting Started Guide]], [[Advanced User Portal]][[Category:Beginner]][[Category* Updated:Server]]The default admin password has been removed.
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu