Jump to category:
 

How do I change the daisyrepository database to UTF-8?

[ This article applies from Daisy version any to version any ]

For newer Daisy versions (1.5, 2.0, ...) the installation instructions create databases using the UTF-8 character set by default. The following information is mainly for people how have been using Daisy since older releases.

Overview

Two steps are involved:

  1. Changing the MySQL database to UTF-8
  2. Daisy configuration change: adding a parameter to the database connection URL

Changing the MySQL database to UTF-8

Foremost, see the MySQL documentation for best advice.

Here is one way to do it.

First make a dump of the daisyrepository database:

mysqldump -uroot daisyrepository > mysqldump.sql

Now open mysqldump.sql file in a texteditor (using utf8 encoding -- at least if you're using MySQL > 4.1.2, which you should), and do a search and replace of:

CHARSET=what-it-is-now

to

CHARSET=utf8

Next go into the mysql tool:

mysql -uroot

and execute:

drop database daisyrepository;
create database daisyrepository CHARACTER SET 'utf8';
exit

and then reload the dump:

mysql -uroot -Ddaisyrepository < mysqldump.sql

Changing Daisy config

Open the myconfig.xml file in a text editor:

<daisyrepodata dir>/conf/myconfig.xml

Look for a line that looks like:

<url>jdbc:mysql://localhost/daisyrepository</url>

If you're using MySQL 5, change the connection URL to:

<url>jdbc:mysql://localhost/daisyrepository?characterEncoding=UTF-8</url>

If you're using MySQL 4.1, change it to:

<url>jdbc:mysql://localhost/daisyrepository?useServerPrepStmts=false&amp;characterEncoding=UTF-8</url>