Changes

Jump to navigation Jump to search
2,138 bytes removed ,  15:00, 25 July 2022
no edit summary
This step by step tutorial is part of article belongs to the [[Getting Started]] Guide.It shows tells you how to run BaseX in client-server mode from a terminal. You can copy and paste all commands to get them 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==First of all, please launch a '''Server''' and '''Client''' instance of BaseX: double click on the '''BaseX Server/Client''' icons, or run the <code>basexserver</code> and <code>basexclient</code> scripts. [[Startup#BaseX Server|Follow this link]] for more information (or check out the additional [[Startup Options#BaseX Server|command-line options]]).
==Create a databaseServer==* To create a database you need an XML document, e.g. [http://files.basex.org/xml/factbook.xml factbook.xml].* Save this document to the directory you are working in.* In the client terminal, type in:<code>> [[Commands#CREATE DATABASE|CREATE DB]] factbook factbook.xml</code>
: '''factbook''' is {{Announce|With Version 10, the name of the database <br/>: '''factbookdefault admin password has been removed.xml''' is the xml file, which is used to create the database<br/> }}
If everything works you see the following lines:<pre>Database 'factbook' created in 950.83 ms.</pre> ; Where is the The database stored?By default, databases are stored in the <code>BaseXData</code> directory, which is located in your home folder.Depending on your server handles concurrent [[Configuration]], the location of your home folder varies. For example, on a Mac it's <code>/Users/John</code>, if your name is John. If you have used the Windows Installer, the directory will be named <code>data</code>, Transaction_Management|read and reside in the application directory. ==Execute a query==The [[Commands#XQUERY|XQUERYwrite transactions]] command lets you run a query.* For example, this query returns all country nodes in the currently opened database.<code>> [[Commands#XQUERYUser Management|XQUERYmanages user permissions]] //country</code> * You can also run queries in files:<code>> and [[Commands#RUNLogging|RUNlogs user interactions]] /Users/John/query.xq</code> ==Create a new database==Now we will create another database from the [httpIt can be started as follows://files.basex.org/xml/xmark.xml xmark.xml] document. * Create the new database, named 'xmark'.<code>> [[Commands#CREATE DATABASE|CREATE DB]] xmark xmark.xml</code>
* Set Run one of the new database xmark as {{Code|basexserver}} or {{Code|basexserver.bat}} scripts. Use {{Code|basexserverstop}} or {{Code|basexserverstop.bat}} to gracefully shut down the context:server.<code>> * If you have installed BaseX on ''Windows'', click on the '''BaseX HTTP Server (Start)''' icon, which will start both the HTTP Server used for [[Commands#OPENWeb Application|OPENWeb Applications]] xmark</code>and the database server. With '''BaseX HTTP Server (Stop)''', you can shut down the server process.
* Now Unless you have already chosen an admin password yet (e.g., via the Windows installer or a previous installation), you can easily execute queries do so by invoking the {{Command|PASSWORD}} command on your new databaseterminal:<code>> [[Commands#XQUERY|XQUERY]] //people/person/name</code>
==Switch the database==
* You can explicitly query the factbook database with the <code>doc(...)</code> funtion, no matter what the current context is.
<pre>
>basexserver -c PASSWORDBaseX [[Commands#XQUERY|XQUERY]Server] docServer was started ("factbook"port: 1984)//country.Password: _
</pre>
* OtherwiseBy default, the server listens to set factbook as the current context, execute port {{Code|1984}}. Pressing {{Code|Ctrl+c}} will close all connections and databases and gracefully shut down the following:<pre>>[[Commands#OPEN|OPEN]] factbook</pre>server process.
* To list the current context, type:<pre>>Various [[CommandsCommand-Line_Options#SHOWServer|SHOWcommand-line options]] DATABASES</pre>are available to simplify batch processing. The [[Start_Scripts|start script]] can be adjusted for individual purposes (e.g. if the default memory limit is too restrictive).
That yields the following lines:==Client==
<pre>1 opened database(s)Database clients are started similarly:- factbook (1x)</pre>
==Close * Run one of the {{Code|basexclient}} or delete a database=={{Code|basexclient.bat}} scripts.* To [[Commands|close]] Execute the current context database, please typefollowing command: <pre>>[[Commands#CLOSE{{Code|CLOSE]]java -cp BaseX.jar org.basex.BaseXClient}}</pre>* If you have installed BaseX on ''Windows'', click on the '''BaseX Client''' icon.
* Use the [[Commands#DROP|DROP]] command At startup, you need to delete the xmark database:<pre>>[[Commands#DROP DATABASE|DROP DB]] xmark</pre>enter your credentials.
==Create a collection=='''What is a collection?'''With BaseX you can group documents into one logical collection. A collection is For further details, have a database that contains two or more documents. Collections accept any type of XML documents, regardless of their structurelook at the [[Command-Line_Options#Client|command-line options]] and the [[Start_Scripts|start script]].
Let's add the xmark.xml document to the factbook database to create a collection. The name of the original factbook database remains.=Introduction=
* First make sure factbook is opened:<pre>>The BaseX command-line client provides similar features to the [[Commands#OPENCommand-Line Client|OPENstandalone client]] factbook<. The major difference is that all commands will be executed by the BaseX server instance. As a consequence, paths/pre>URIs to resources need to be resolvable by the server (file contents will not be transfered to the server).
* Now add 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 xmark.xml documentcommand line:
<pre>
>[[Commands#ADD|ADD]] xmarkbasexclient -V -Uadmin -P...xml-c "CREATE DB input <example/pre>; XQUERY /"
==Delete a document==* Deleting a document from a collection is easy:Database 'input' created in 13.85 ms.<preexample/>>[[Commands#DELETE|DELETE]] xmark.xmlQuery:</pre>
Make sure that the collection, which contains the '''xmarkParsing: 0.xml''' document, is opened18 msCompiling: 0.04 msEvaluating: 0.12 msPrinting: 0.07 msTotal Time: 0.41 ms
==Delete a collection==Hit(s): 1 ItemDeleting a collection is the same as deleting a database.Updated: 0 ItemsPrinted: 10 BytesRead Locking: local [input]Write Locking: none
* To delete the collection factbook, type:<pre>>[[Commands#DROP DATABASE|DROP DB]] factbook</pre> ==Get server information==Several commands help to explore the state of a serverQuery "user" executed in 0. For a complete list, please visit the [[Commands]] Section41 ms* To see all databases on the server, type:<pre>>[[Commands#LIST|LIST]]
</pre>
* To see which database is currently opened:<pre>>[[Commands#SHOW DATABASES|SHOW DATABASES]]</pre> * To see the general information of the opened database, type:<pre>>[[Commands#INFO|INFO]]</pre> * To see the users in BaseX, type:<pre>>[[Commands#SHOW USERS|SHOW USERS]]</pre> =Language Bindings=Backup and restore==* To backup your database, type:<pre>> [[Commands#CREATE BACKUP|CREATE BACKUP]] factbook</pre> * To restore your database, type:<pre>> [[Commands#RESTORE|RESTORE]] factbook</pre>
'''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 Mode]], [[GUI]], [[Getting Started]], [[Advanced Usage]][[Category:Beginner]][[Category* Updated:Server]]The default admin password has been removed.
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu