Changes

Jump to navigation Jump to search
1,718 bytes removed ,  12:15, 15 February 2021
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.
==Startup==See the [[Startup Overview]].
==First OperationsServer==To get familiar with BaseX we suggest to execute the following basic operations.
===Create a The database===* To create a database you need an XML documentserver handles concurrent [[Transaction_Management|read and write transactions]], e.g. [http://www.w3.org/XML/Binary/2005/03/test-data/Over100/factbook.xml factbook.xml[User Management|manages user permissions]] and [[Logging|logs user interactions]].* Save this document to the directory your working in.* On the client terminal runIt can be started as follows: <code>: > create db factbook factbook.xml</code>
: * Run one of the {{Code|basexserver}} or {{Code|basexserver.bat}} scripts. Add the {{Code|stop}} keyword to gracefully shut down the server.* If you have installed BaseX on ''factbookWindows'' - is , click on the name of the database <br/>: ''factbook.xml'BaseX HTTP Server (Start)''' - is the xml fileicon, which is will start both the HTTP Server used to create for [[#Web Application|Web Applications]] and the database<br/> server. With '''BaseX HTTP Server (Stop)''', you can shut down the server process.
If everything works you see the following lines:<pre>Database 'factbook' created in 1950.83 ms.</pre> ; Where is By default, the database stored?Databases are stored in server listens to the BaseXData directory which is located in your home folderport {{Code|1984}}. Depending on your operating system Pressing {{Code|Ctrl+c}} will close all connections and databases and gracefully shut down the location of your home folder varies. For example, on a mac it's /Users/John, if your name is Johnserver process.
===Execute a query===Various [[Command-Line_Options#Server|command-line options]] are available to simplify batch processing. The [[CommandsStart_Scripts|xquerystart script]] command lets you run a querycan be adjusted for individual purposes (e.g.* For example, this query returns all country nodes in if the currently opened databasedefault memory limit is too restrictive).<code>: > xquery //country</code>
* You can also run queries in files:<code>: > run /Users/John/query.xq</code>==Client==
===Create a new database===Now we will create another database. You can find the example document hereDatabase clients are started similarly: [http://phobos101.inf.uni-konstanz.de/basex/demo].
* Create Run one of the new database, named 'xmark'{{Code|basexclient}} or {{Code|basexclient.bat}} scripts.<code>* Execute the following command: > create db xmark xmark{{Code|java -cp BaseX.xmljar org.basex.BaseXClient}}</code>* If you have installed BaseX on ''Windows'', click on the '''BaseX Client''' icon.
* Set At startup, you need to enter your credentials. The initial passwort of the new database xmark as {{Code|admin}} user is {{Code|admin}}; it can be changed with the context:<code>: > open xmark</code>{{Code|[[Commands#PASSWORD|PASSWORD]]}} command.
* Now you can easily execute queries on your new database:<code>: > xquery //people/person/name</code>For further details, have a look at the [[Command-Line_Options#Client|command-line options]] and the [[Start_Scripts|start script]].
=Introduction==Switch the database===* You can explicitly query the factbook database with the doc()-funtion, no matter what the current context is.<code>: > xquery doc("factbook")//country</code>
* Otherwise, The BaseX command-line client provides similar features to set factbook as 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, execute the following:<code>: > open factbook<paths/code> * To list URIs to resources need to be resolvable by the current context, type:<code>: > show databases</code> That yields 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 -Padmin -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 xmarkQuery "user" executed in 0.xml document to the factbook database to create a collection. The name of the original factbook database remains41 ms* First make sure factbook is opened:<code>: > open factbook</codepre* 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 server. For a complete list visit the [[Commands|commands section]]. * 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</code> To restore your database, type::<code>> restore factbook</code> '''Where is the backup-file stored?'''
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.=Language Bindings=
==See also ==[[Standalone Tutorial]], [[GUI Tutorial]], [[Getting Started]]If you want to communicate with the database server programmatically, we provide clients for various [[Advanced Usage]][[Category:Beginner]][[Category:ServerClients|programming languages]].
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu