summaryrefslogtreecommitdiffstats
path: root/askbot/doc/source/create-database.rst
blob: 9b262af784abe0724d777cdc1b0667487d3e5479 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
.. _create-database:

==========================
Create database for Askbot
==========================

Askbot has been successfully tested with `MySQL` and `PostgreSQL` databases.

PostgreSQL
----------
PostgreSQL is the preferred database for Askbot - because it offers great
full text search functionality and supports transactions at the same time.

To use postgresql - install it (please see documentation elsewhere).

After you have the database inself, add python bindingngs to postgresql::

    pip install psycopg2

To create a database, log in to postgresql as user postgres, create a user (if necessary), create a database, and enable the user account to log in to the database::

    create role someuser with createdb login encrypted password `somepassword`;
    create database somedb with owner=someuser;

Then edit file ``pg_hba.conf`` within your database installation and add a line as the first non-comment line or near, to make sure that this rule takes precedence::

    local somedb someuser md5

Then restart the database server (probably as root user), the command may be::

    /etc/init.d/postgresql restart

MySQL
-----
This section assumes that MySQL is installed and is up and running.

Once you have the database installed (please see manual elsewhere), add python bindings for mysql::

    pip install mysql-python

Database can be prepared via your hosting control panel, if available, or
can be created manually as shown below (using a high privilege MySQL account):

Log in to mysql::

    mysql -u username -p

Then type these two commands (note that fake `dbname`, `dbuser`, and `dbpassword` are used in this example)::

    create database askbot DEFAULT CHARACTER SET UTF8 COLLATE utf8_general_ci;
    grant all privileges on dbname.* to dbuser@localhost identified by 'dbpassword';

Again, please remember to create real usernname, database name and password and write them down. These
credentials will go into the file `settings.py`_ - the main configuration file of the Django application.

.. note::

    Notation `dbuser@hostname` is important for security - normally you want to restrict access to
    the database to certain hosts only. `localhost` entry ensures that database cannot be accessed
    from remote hosts at all.

.. _Python: http://www.python.org/download/
.. _MySQL: http://www.mysql.com/downloads/mysql/#downloads 
.. _settings.py: http://github.com/ASKBOT/askbot-devel/blob/master/askbot/setup_templates/settings.py