Changes

Jump to navigation Jump to search
1,899 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 BaseXThe database server handles concurrent [[Transaction_Management|read and write transactions]], [[User Management|manages user permissions]] and [[Logging|logs user interactions]].jar org.basex.BaseXServer -i</code> :Or the server It can be started alternatively without the -i flag. Note, that you have to restart the server to execute further commands from this shell.<code>as follows: > java -cp BaseX.jar org.basex.BaseXServer</code>
*A default admin user is created (Run one of the {{Code|basexserver}} or {{Code|basexserver.bat}} scripts. Use {{Code|basexserverstop}} or {{Code|basexserverstop.bat}} to gracefully shut down the server.* If you can change have installed BaseX on ''Windows'', click on the password with '''BaseX HTTP Server (Start)''' icon, which will start both the HTTP Server used for [[Commands#Web Application|PASSWORDWeb Applications]] command)::Username: admin:Password: admin *Once and the database server has successfully started . With '''BaseX HTTP Server (Stop)''', you see can shut down the following lines:<pre>BaseXServer [Server]Server was startedserver process.</pre>
===Starting Unless you have already chosen an admin password yet (e.g., via the Client===*Open Windows installer or a new terminal windowprevious installation), make sure you are in can do so by invoking the right directory (/basex).*Execute the following to start the client:<code>{{Command|PASSWORD}} command on your terminal:> java -cp BaseX.jar org.basex.BaseXClient</code>
*If you haven't changed the password with the server, you can login as default user (admin/admin).<pre>basexserver -c PASSWORD==First Operations==To get familiar with BaseX we suggest to execute the following basic operations. ===Create 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 runServer was started (port: <code>: > create db factbook factbook.xml</code> : ''factbook'' - is the name of the database <br/>: ''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.
===Execute 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=Create a new database / switch between databases===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.
===Close or delete For further details, have a database===If you want to close look at the opened database, simply type::<code>> close</code>[[Command-Line_Options#Client|command-line options]] and the [[Start_Scripts|start script]].
If you want to delete the xmark database, use::<code>> drop db xmark</code>=Introduction=
===Create a collection==='''What is a collection?'''With The BaseX you can group documents into one logical collectioncommand-line client provides similar features to the [[Command-Line Client|standalone client]].A collection The major difference is a database that contains two or more documentsall commands will be executed by the BaseX server instance.You can put any type of XML documents into As a consequence, paths/URIs to resources need to be resolvable by the collection, regardlessof their structureserver (file contents will not be transfered to the server).
Now we will add the xmarkUsername and password can also be specified as command-line option.xml document to To evaluate commands without entering the factbook databaseconsole mode,you can use the <code>-c</code> option on the command line:and thus create a collection <pre>basexclient -V -Uadmin -P.. The collection will keep the name factbook.-c "CREATE DB input <example/>; XQUERY /"
First make sure factbook is opened:Database 'input' created in 13.85 ms.:<codeexample/>> open factbookQuery:</code>
Now add the xmarkParsing: 0.xml document18 msCompiling: 0.04 msEvaluating:<code>0.12 ms> add xmarkPrinting: 0.xml07 ms</code>Total Time: 0.41 ms
===Delete a document from a collection===Hit(s): 1 ItemDeleting a document from a collection is very easy, just typeUpdated:0 ItemsPrinted:<code>10 Bytes> delete xmark.xmlRead Locking: local [input]</code>Write Locking: none
N.B. The collection has to be the context iQuery "user" executed in 0.e. the database whichcontains the document has to be opened. ===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