Installing Trac with MySQL database
1. Follow the basic guide posted here.
2. Be sure to install python-mysqldb package.
3. Create MySQL database and user for trac.
CREATE DATABASE trac; CREATE USER trac IDENTIFIED BY 'trac'; GRANT ALL privileges ON trac.* TO 'trac'@'%'; |
4. Run the following command:
trac-admin <Your project dir> initenv |
5. When asked for the MySQL connection url enter something like the following:
#form: db-type://username:password@mysql-host:mysql-port/databasename mysql://trac:trac@localhost:3306/trac |
6. Configuring Apache2 (Make sure you have mod_python)
<Location /trac/test> SetHandler mod_python PythonInterpreter main_interpreter PythonHandler trac.web.modpython_frontend PythonOption TracEnv /var/trac/test PythonOption TracUriRoot /trac/test </Location> <LocationMatch "/trac/[^/]+/login"> AuthType Basic AuthName "Trac" AuthUserFile /var/trac/trac.htpasswd Require valid-user </LocationMatch> |
7. Add admin login data
htpasswd -c /var/trac/trac.htpasswd admin |
8. Grant TRAC_ADMIN to admin user
trac-admin /var/trac/test permission add admin TRAC_ADMIN |
I found necessary to perform the following steps (I don’t know non-standard my trac installation is). I don’t know why the upgrade fails, but I compared the sqlite dump and found a column missing in the milestones table.
1. In the [trac] section of the conf/trac.ini file I needed to add the following:
database = mysql://trac:trac@localhost:3306/trac
database_charset = latin1
1.1 Reload the apache server
/etc/rc.d/init.d/httpd restart
2. trac-admin project-dir upgrade
I get an error there about a table, then
3. In mysql
drop table milestone;
create table milestone (
name varchar(255) primary key,
due int(11) null default null,
completed int(11) null default null,
started int(11) null default null,
description text null default null);
INSERT INTO milestone VALUES (‘milestone1’,0,0,0,NULL);
INSERT INTO milestone VALUES (‘milestone2’,0,0,0,NULL);
INSERT INTO milestone VALUES (‘milestone3’,0,0,0,NULL);
INSERT INTO milestone VALUES (‘milestone4’,0,0,0,NULL);
4. Try again the upgrade…