Changes

Jump to navigation Jump to search
2,006 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 administration of BaseX. Visit the [[Commands|commands section]] for a complete list of database commandscommand-line.
The server/client environment of BaseX offers the following features:* ACID safe transactions, with multiple readers and single writers * User management with global and local permissions * Password authentication via cram-md5 * Logging of server activity If you run BaseX for the first time, a default admin user is created:* <b>Username:</b> <code>admin</code>* <b>Password:</b> <code>admin</code>=Startup=
The password can be changed using the <code>[[Commands#PASSWORD|PASSWORD]]</code> commandor the GUI server dialog.==Server==
The BaseX server can be started via the GUI server dialog or{{Announce|With Version 10, as shown in the [[Startup Overview]]default admin password has been removed.}}
==Startup==See the The database server handles concurrent [[Startup OverviewTransaction_Management|read and write transactions]], [[User Management|manages user permissions]] and [[Logging|logs user interactions]].It can be started as follows:
==First Operations==* Run one of the {{Code|basexserver}} or {{Code|basexserver.bat}} scripts. Use {{Code|basexserverstop}} or {{Code|basexserverstop.bat}} to gracefully shut down the server.To get familiar with * If you have installed BaseX we suggest to execute on ''Windows'', click on the '''BaseX HTTP Server (Start)''' icon, which will start both the HTTP Server used for [[#Web Application|Web Applications]] and the database server. With '''BaseX HTTP Server (Stop)''', you can shut down the following basic operationsserver process.
===Create a database===* To create a database Unless you need have already chosen an XML document, admin password yet (e.g. [http://www.w3.org/XML/Binary/2005/03/test-data/Over100/factbook.xml factbook.xml].* Save this document to , via the /basex directory.* On Windows installer or a previous installation), you can do so by invoking the client {{Command|PASSWORD}} command on your terminal run: <code>: > create db factbook factbook.xml</code>
: ''factbook'' - is the name of the database <br/pre>: ''factbook.xml'' basexserver - is the xml file, which is used to create the database<br/> c PASSWORDBaseX [Server]If everything works you see the following linesServer was started (port:1984).<pre>Database 'factbook' created in 1950.83 ms.Password: _
</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===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.
===Switch 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 /"
===Close or delete a database===* To [[Commands|close]] the current context database type: Database 'input' created in 13.85 ms.<codeexample/>Query: > close</code>
* Use the [[Commands|drop]] command to delete the xmark databaseParsing:0.18 ms<code>Compiling: 0.04 msEvaluating: 0.12 msPrinting: > drop db xmark0.07 ms</code>Total Time: 0.41 ms
===Create a collection===Hit(s): 1 Item'''What is a collection?'''Updated: 0 ItemsWith BaseX you can group documents into one logical collection. A collection is a database that contains two or more documents. Collections accept any type of XML documents, regardless of their structure.Printed: 10 BytesRead Locking: local [input]Write Locking: none
Let's add the xmark.xml document to the factbook database to create a collection. The name of the original factbook database remains. * 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:<code>: > delete xmark.xml</code> Make sure the collection which contains the xmark.xml document is opened. ===Delete a collection===Deleting a collection is the same as deleting a database. * To delete the collection factbook, type:<code>: > drop factbook</code> ===Get information about the server===Several commands help to explore the state of a serverQuery "user" executed in 0. For a complete list visit the [[Commands|commands section]]41 ms* To see all databases on the server, type:<code>: > list</code> * To see which database is currently opened:<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 database directory.The file is named <code>factbook-timestamp.zip</code> (<code>db_name-timestamp.zip</code>).To restore the database the file with the newest timestamp is taken.=Changelog=
==See also ==;Version 10.0[[Standalone Tutorial]], [[GUI Tutorial]], [[Getting Started]], [[Advanced User Portal]][[Category:Beginner]][[Category* Updated:Server]]The default admin password has been removed.
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu