From The Mana World
m (Jaxad0127 moved page Database Installation to Archive:Database Installation without leaving a redirect)
(No difference)

Revision as of 18:06, 24 June 2013

This page is currently WIP and should describe how to set up the database for a new installation of tmwserv. This page should be moved to Setting up a server when finished.


Before you can set up your own server you have to decide wich database backend you want to use. Currently, the server supports three different types of database backends:

  • mySQL
  • SQLite
  • PostgreSQL


Settings up mySQL

Requirements

To run tmwserv with mySQL you should use a mySQL version >= 5.0.*. It was tested sucessfully with 5.0.51a. Also you have to enable the InnoDB storage engine as tmwserv makes use of the relational and transactional features.

Creating a database and a user

This chapter assumes, that you still have little experience working with mysql, so it does not describe how to install mysql itself. The first step to get tmwserv running under mySQL would be the creation of a database and a user. As you can easily do this with graphical frontends like phpMyAdmin, we will give you a handy script for doing that from command line. Don't forget to replace the placeholders with appropriate values for your environment.

For the following commands you have to be logged in as a database administrator, preferable root.

-- create a user called tmw (modify this as you whish)
-- the 'localhost' says, that our new user is only allowed from our local machine
CREATE USER 'tmw'@'localhost' IDENTIFIED BY '<insert your password preferred here>';
-- allow the user to connect to the server without any resource limitations
GRANT USAGE ON * . * TO 'tmw'@'localhost' IDENTIFIED BY '<again your pwd>' 
   WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;
-- create a new database called 'tmw' but you can name it just as you like
CREATE DATABASE IF NOT EXISTS `tmw` ;
-- give our new user full privileges on our new created database
GRANT ALL PRIVILEGES ON `tmw` . * TO 'tmw'@'localhost';
   

Summarized, now we have a new database called tmw, a new database user tmw that has full rights in his database, and a restriction, that he is only able to connect from localhost.

Create database tables

If our new database user is ready for use, we have to create all necessary tables. The installation of tmwserv provides you with a ready to use database script. You can find this script under ./src/sql/mysql/createTables.sql To run this script connect as user tmw with your database.

mysql --host localhost --user tmw --password --database tmw --no-beep

After typing your password you should be connected to the database. The command \. runs a database script.

\. <path to the script>/createTables.sql
-- e.g.
\. ~/tmwserv/src/sql/mysql/createTables.sql

Configuring tmwserv to use the database

TODO


Settings up SQLite

Requirements

Tmwserv has been tested with SQLite version 3.5.8

Preparation of database file

The creation of a new database file is very easy. Just go to the directory where you want to create it and type:

sqlite3 tmw.db < ${tmwserv-dir}/src/sql/sqlite/createTables.sql

This will create the tmw.db file and execute the SQL statements in createTables.sql. To verify if the installation was sucessful you could do:

$ sqlite3 tmw.db
sqlite> .tables

This should give you a list of tmw_* tables.

Configuring tmwserv to use the database

Before starting tmwserv you have to configure the account server where your database file is located. Tmwserv uses a XML file called tmwserv.xml with an easy to read key = value structure. Locate the option sqlite_database and modify the value attribute according to your environment. You can use a relative path starting at the location of your tmwserv executeable.

<option name="sqlite_database" value="./tmw.db"/>

Settings up PostgreSQL

TODO