|Version 23 (modified by 14 years ago) ( diff ),|
MySQL and the MySQLdb Python bindings for MySQL
It is somewhat supported by Trac since 0.10, but there are some limitations (see #KnownIssues). Use this only if you don't have other choice, and be warned that there can be many issues, in particular related to the unicode support and the repository cache support. Some users are nevertheless using MySQL successfully, so it might work for you. The primary supported backends though are PostgreSQL and SQLite.
In order to avoid several issues with unicode and international characters throughout Trac (e.g., international characters turning into question marks with mysterious "Incorrect string value" errors logged), we strongly advise MySQL users to only use databases having the
utf8 character set and the
utf8_bin collation type. However, changing collation to utf8 makes MySQL fail in 4.1.x and 5.0.x versions on MyISAM table type, because some Trac tables indexes become "too big". This will be (hopefully) addressed in 0.10.4. As a workaround it has been recommended to use InnoDB tables instead of MyISAM where this limitation is absent.
Such databases can be created with the MySQL monitor, like that:
CREATE DATABASE trac DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
Some unicode related MySQL-python bugs were worked around in r7286 so if you're experiencing problems with non-ascii text you should consider upgrading to Trac 0.11-stable or wait until Trac 0.11.1 is released.
To check character set settings for your database, issue command:
mysql> USE trac; Database changed mysql> SHOW VARIABLES LIKE '%character%'; +--------------------------+-------------------- | Variable_name | Value +--------------------------+-------------------- | character_set_client | cp1251 | character_set_connection | cp1251 | character_set_database | utf8 | character_set_filesystem | binary | character_set_results | cp1251 | character_set_server | utf8 | character_set_system | utf8 | character_sets_dir | C:\DevServer\Instal +--------------------------+-------------------- 8 rows in set (0.00 sec) mysql>
See also #3884.
Usually, you also want to create a user and give this user access to the database created above:
CREATE USER tracuser IDENTIFIED BY 'password'; GRANT ALL ON trac.* TO tracuser;
The connection string will then be:
The recommended version is MySQL-python 1.2.2.
See http://cheeseshop.python.org/pypi/MySQL-python/1.2.2, which contains links to the .tar.gz source distribution as well as pre-built Windows eggs.
Older versions can be found at the mysql-python sourceforge project:
- MySQL-python 1.2.1_p2 was the previously recommended version
- MySQL-python 1.2.0-3.2.2, MySQL-python 1.2.2b2) were reported to have issues (see #3645).
- MySQL-python-1.2.2b2 was reported to solve an
AttributeError: 'array.array' object has no attribute 'startswith'error seen when viewing a changeset… These problems ought to be fixed in 1.2.2b3; if they are not, or if you have other issues, please file a bug in the MySQL-python Bug Tracker.
next-dev-1.7.x milestone tickets:
- Add [trac] mysql_storage_engine option instead of editting my.cnf
next-major-releases milestone tickets:
- MySQL schema changes for performance
- Reduce join in query process
- Attachment table primary key not unique when migrating from SQLite to MySQL
next-stable-1.4.x milestone tickets:
- Add a script to contrib for converting MySQL storage engine
- Support ucs2/utf16/utf32 charset and utf16_bin/utf32_bin collation in MySQL
unscheduled milestone tickets:
- Error when adding or viewing a ticket using MySQL
- Problems with database encoding
- Encoding problem with mysql
- initenv problem with MySQL - Access Denied
- install error (mysql)
- TypeError: unhashable type when installing trac-0.10.3 with mysql
- 'module' object has no attribute 'connect'
- InterfaceError: (0, '') after idle period with mod_wsgi 1.1/Apache 2.2.3
- trac-admin allows to init environment with mysql errors
- Trac 0.10.4 - ticket module provider fails in background
- IntegrityError when not logged in
- Formatted time via SQL command FROM_UNIXTIME fails to replace %*
- OperationalError: (2002, "Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (13)")
- TypeError: int() argument must be a string or a number
- TypeError: unsupported type for timedelta microseconds component: unicode
- OperationalError: (1030, 'Got error 28 from storage engine')
- Problem with synchronizing svn commits to MySQL database
- The $ character must be URL encoded if used as a database password
(corresponding custom query)