Changes

Jump to navigation Jump to search
460 bytes removed ,  11:51, 12 January 2011
m
Reverted edits by AW (talk) to last revision by CG
This step by step tutorial shows 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 commands.
 
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>
 
The password can be changed using the <code>[[Commands#PASSWORD|PASSWORD]]</code> command
or the GUI server dialog.
 
The BaseX server can be started via the GUI server dialog or, as shown in the [[Startup Overview]].
==Startup==
==First Operations==
To get to know familiar with BaseX, we advise suggest to run some of execute the following basic operations to see how it works andget your first indentations.
===Create a database===
In order to * To create a database you need a xml-an XML document, e.g. [http://www.w3.org/XML/Binary/2005/03/test-data/Over100KOver100/factbook.xml factbook.xml].<br/>* Save this document to the /basex directory.* On the client terminal run: :<code>: > create db factbook factbook.xml
</code>
<br/>
''factbook'' - is the name of the database <br/>
''factbook.xml'' - is the xml file, which is used to create the database<br/>
: ''factbook'' - is the name of the database <br/>: ''factbook.xml'' - is the xml file, which is used to create the database<br/>  If everything works, this message will appear, you see the time might differ.following lines:
<pre>Database 'factbook' created in 1950.83 ms.
</pre>
;Where is the database stored?It is Databases are stored in the BaseXData directory which is located in your home directoryfolder. Depending on your operating system the location of your home folder varies.In my case For example, on a mac it's in /Users/JohnDoe/BaseXData/factbookJohn, if your name is John.
===Execute a query===
To The [[Commands|xquery]] command lets you run a query the xquery command is used. After '''xquery''' you can insertany valid xquery you like. <br/>This * For example, this query returns all the countries country nodes in the currently opened database.:<code> : > xquery //country
</code>
<br/>
If you wish, you * You can also save your query run queries in a file, and run it on basex.files::<code>: > run /pathToQueryUsers/John/query.txtxq
</code>
===Create another a new database, switch between databases===Now we will create an another database. You can get find the xml example document from here : [http://phobos101.inf.uni-konstanz.de/basex/demo].:* Create the new database, named 'xmark'.<code>: > create db xmark xmark.xml
</code>
To set * Set the new database xmark as the context (the active, opened database), use::<code>: > open xmark
</code>
* Now you can simply type easily execute queries on your xquerynew database::<code>: > xquery //people/person/name
</code>
If you want to ===Switch the database===* You can explicitly query the factbook database you can access it by explicitly naming it with the doc()-functionfuntion, no matter what the current context is.:<code> : > xquery doc("factbook")//country
</code>
If you want * Otherwise, to set the factbook database as the current context, you can useexecute the following::<code>: > open factbook
</code>
* To see which database is openedlist the current context, usetype::<code>: > show databases
</code>
 
That yields the following lines:
 
<pre>
1 opened database(s):
- factbook (1x)
</pre>
===Close or delete a database===
If you want to * To [[Commands|close ]] the opened current context database, simple type::<code>: > close
</code>
If you want * Use the [[Commands|drop]] command to delete the xmark database, use::<code>: > drop db xmark
</code>
===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 Collections accept any type of XML documents into the collection, regardlessof their structure.
Now we will Let's add the xmark.xml document to the factbook database,and thus to create a collection. The collection will keep name of the name original factbookdatabase 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, just type::<code>: > delete xmark.xml
</code>
N.B. The Make sure the collection has to be the context i.e. the database whichcontains the xmark.xml document has to be is opened.
===Delete a collection===
Deleting a collection is the same as deleting a database.
If you want to * To delete the collection factbook, type::<code>: > drop factbook
</code>
===Getting 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 in BaseXon 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 RestroreRestore===
To backup your database, type:
:<code>
</code>
'''Where is the backup -file stored?'''
The backup-file is stored in the BaseXData directory, which is in your home 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.
bueraucrat, Bureaucrats, editor, reviewer, Administrators
907

edits

Navigation menu