- new test
[oweals/gnunet.git] / doc / README.mysql
1 How to setup the MySQL database for GNUnet.
2
3 NOTE: This db module does NOT work with mysql before 4.1 since we need
4 prepared statements.  We are generally testing the code against MySQL
5 5.0 at this point.
6  
7 HIGHLIGHTS
8
9 Pros
10  + On up-to-date hardware where mysql can be used comfortably, this
11    module will have better performance than the other db choices
12    (according to our tests). 
13  + Its often possible to recover the mysql database from internal 
14    inconsistencies. The other db choices do not support repair 
15    (gnunet-check cannot fix problems internal to the dbmgr!). 
16    For example, we have seen several cases where power failure 
17    has ruined a gdbm database beyond repair. 
18  + much faster (for one of the key benchmarks -- content migration
19    -- we have measure mysql taking 2s for an operation where
20    sqlite takes 150s).
21 Cons 
22  - Memory usage (Comment: "I have 1G and it never caused me trouble")
23  - Manual setup
24
25 MANUAL SETUP INSTRUCTIONS
26
27  1) in /etc/gnunet.conf, set
28     DATABASE = mysql
29
30  2) Then access mysql as root,
31     $ mysql -u root -p 
32     and do the following. [You should replace $USER with the username 
33     that will be running the gnunetd process].
34
35       CREATE DATABASE gnunet;
36       GRANT select,insert,update,delete,create,alter,drop,create temporary tables
37          ON gnunet.* TO $USER@localhost;
38       SET PASSWORD FOR $USER@localhost=PASSWORD('$the_password_you_like');
39       FLUSH PRIVILEGES;
40
41  3) In the $HOME directory of $USER, create a ".my.cnf" file 
42     with the following lines
43  
44       [client]
45       user=$USER
46       password=$the_password_you_like
47     
48  Thats it. Note that .my.cnf file is a security risk unless its on
49  a safe partition etc. The $HOME/.my.cnf can of course be a symbolic
50  link. Even greater security risk can be achieved by setting no 
51  password for $USER.  Luckily $USER has only priviledges to mess 
52  up GNUnet's tables, nothing else (unless you give him more, 
53  of course).
54
55  4) Still, perhaps you should briefly try if the DB connection 
56     works. First, login as $USER. Then use,
57
58     $ mysql -u $USER
59     mysql> use gnunet;
60     
61     If you get the message "Database changed" it probably works.
62  
63     [If you get "ERROR 2002: Can't connect to local MySQL server 
64      through socket '/tmp/mysql.sock' (2)" it may be resolvable by
65      "ln -s /var/run/mysqld/mysqld.sock /tmp/mysql.sock"
66      so there may be some additional trouble depending on your mysql setup.]
67
68  5) If you want to run the testcases, you must create a second
69     database "gnunetcheck" with the same username and password.
70     This database will then be used for testing ("make check").
71
72
73 REPAIRING TABLES 
74
75 - Its probably healthy to check your tables for inconsistencies
76   every now and then, especially after system crashes.
77 - If you get odd SEGVs on gnunetd startup, it might be that the mysql
78   databases have been corrupted. 
79 - The tables can be verified/fixed in two ways;
80   1) by shutting down mysqld (mandatory!) and running 
81   # myisamchk -r *.MYI 
82   in /var/lib/mysql/gnunet/ (or wherever the tables are stored).
83   Another repair command is "mysqlcheck". The usable command
84   may depend on your mysql build/version. Or,
85   2) by executing 
86   mysql> REPAIR TABLE gn090;
87
88
89 PROBLEMS?
90
91 If you have problems related to the mysql module, your best friend is
92 probably the mysql manual. The first thing to check is that mysql is
93 basically operational, that you can connect to it, create tables,
94 issue queries etc.
95