Proper database can be created with the MySQL monitor, like that:
CREATE DATABASE trac DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
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:
mysql://tracuser:password@localhost/trac
Troubleshooting
If you get an error from python when using trac-admin like this:
OperationalError: (1045, "Access denied for user 'tracuser'@'localhost' (using password: YES)")
There are a few possibilities:
- Try first to login on the command-line using the user tracuser (mysql -p -h localhost -u tracuser)
- Created user is not yet used by MySQL (Login to the MySQL server(as root):
mysql -pand typeFLUSH PRIVILEGES;) - The user is added but the host does not match in the mysql user table (I had this on my FreeBSD setup).
mysql -p; use mysql; UPDATE user SET Host="localhost" WHERE User="tracuser"; FLUSH PRIVILEGES;)