Changeset 4637


Ignore:
Timestamp:
Nov 17, 2008, 11:38:42 AM (15 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #1168: Require UTF-8 to be used as database character set

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/config/dist/base.config

    r4508 r4637  
    3030db.dialect          = org.hibernate.dialect.MySQLInnoDBDialect
    3131db.driver           = com.mysql.jdbc.Driver
    32 db.url              = jdbc:mysql://localhost/base2?useCursorFetch=true&defaultFetchSize=100&useServerPrepStmts=true
     32db.url              = jdbc:mysql://localhost/base2?characterEncoding=UTF-8&useCursorFetch=true&defaultFetchSize=100&useServerPrepStmts=true
    3333db.dynamic.catalog  = base2dynamic
    3434db.queries          = /mysql-queries.xml
  • trunk/doc/configure_unicode_support.txt

    r2940 r4637  
    7070look in the documentation for that container how to make the configuration
    7171in step 2.
    72 
    73 
    74 Other character encodings
    75 -------------------------
    76 Of course, you are not limited to the UTF-8 character encoding. You can specify
    77 any encoding you want as long as the encoding is supported by both the database
    78 and the servlet container. If you want to change the encoding after the database
    79 has been created and populated with data you must somehow tell the database engine
    80 to convert the existing data to the new encoding. For instructions how to do that
    81 (it might be impossible) look in the documentation for your database.
    82 
  • trunk/doc/src/docbook/admindoc/installation_upgrade.xml

    r4589 r4637  
    6565    <title>Upgrade instructions</title>
    6666
     67    <important id="useUTF8">
     68      <title>BASE 2.9 must use a database that supports UTF-8</title>
     69      <para>
     70        If you are upgrading from BASE 2.8 or lower and your existing
     71        database is not using UTF-8 you must convert the database to
     72        UTF-8 <emphasis>before you execute the <code>./updatedb.sh</code></emphasis>
     73        script.
     74      </para>
     75      <para>
     76        BASE 2.9 includes a utility that can convert an existing MySQL
     77        database. After installing the BASE 2.9 files, but <emphasis>before</emphasis>
     78        running the <code>./updatedb.sh</code> script, execute the following
     79        on the command line:
     80      </para>
     81      <programlisting>
     82<![CDATA[
     83cd <base-dir>/bin
     84./onetimefix.sh utf8 -x
     85]]>
     86</programlisting>
     87     
     88      <para>
     89        The <code>-x</code> option makes the script update the database immediately.
     90        You can leave this option out to have it generate a SQL script file
     91        (<filename>convert-to-utf8.sql</filename>) instead. The script will by default
     92        not try to convert tables that it already thinks are using UTF-8. If the script
     93        for some reason is incorrect when detecting this, you can use the option
     94        <code>-f</code> to force conversion of all tables.
     95      </para>
     96
     97      <para>
     98        The conversion utility only works with MySQL. PostgreSQL users should
     99        instead use a backup and restore using as described in the
     100        <ulink url="http://www.postgresql.org/docs/8.1/static/backup.html">PostgreSQL manual</ulink>.
     101        Eg. dump the existing BASE database, create a new database that uses UTF8 and
     102        restore the backup into the new database.
     103      </para>
     104    </important>
     105   
    67106    <important id="lowess_bug">
    68107      <title>Bug in the LOWESS plug-in affecting BASE version 2.0 -- 2.7.1</title>
     
    872911            is never used to log on to the BASE application.
    873912          </note>
     913          <important>
     914            <title>The database must use the UTF-8 character set</title>
     915            <para>
     916              Otherwise there will be a problem with storing values
     917              that uses characters outside the normal Latin1 range, for
     918              example unit-related such as µ (micro) and Ω (ohm).
     919            </para>
     920          </important>
    874921          <variablelist>
    875922            <varlistentry>
     
    886933                  new database. To do this, connect to your MySQL
    887934                  server and issue the next lines:
    888 <programlisting>CREATE DATABASE base2;
    889 CREATE DATABASE base2dynamic;
     935<programlisting>CREATE DATABASE base2 DEFAULT CHARACTER SET utf8;
     936CREATE DATABASE base2dynamic DEFAULT CHARACTER SET utf8;
    890937GRANT ALL ON base2.* TO db_user@localhost IDENTIFIED BY 'db_password';
    891938GRANT ALL ON base2dynamic.* TO db_user@localhost;</programlisting>
    892                 </para>
     939                </para>             
    893940                <para>
    894941                  The <filename>&lt;base-dir&gt;/misc/sql/createdb.mysql.sql</filename>
     
    917964  # this will prompt for an password for the new user, and issue two
    918965  # more question that should be answered with character 'n' for no.
    919 createdb --owner db_user --encoding UNICODE base2
     966createdb --owner db_user --encoding UTF8 base2
    920967psql base2
    921968  # this will start the psql command line tool. Issue the next line
  • trunk/doc/src/docbook/appendix/base.config.xml

    r4509 r4637  
    113113          <note>
    114114            <para>
    115             For MySQL we recommend that you enable the server-side cursors feature.
    116             It will reduce memory usage since the JDBC driver does not have to
    117             load all data into memory:
     115            For MySQL we recommend that you set the character encoding to UTF-8
     116            and enable the server-side cursors feature. The latter option will
     117            reduce memory usage since the JDBC driver does not have to
     118            load all data into memory. The value below should go into one line
    118119            <userinput>
    119             jdbc:mysql://localhost/base2?useCursorFetch=true&amp;defaultFetchSize=100
     120            jdbc:mysql://localhost/base2?characterEncoding=UTF-8&amp;
     121              useCursorFetch=true&amp;defaultFetchSize=100&amp;useServerPrepStmts=true
    120122            </userinput>
    121123            </para>
  • trunk/misc/sql/createdb.mysql.sql

    r4509 r4637  
    3939  corresponding changes in your base.config file.
    4040*/
    41 
    4241CREATE DATABASE `base2` DEFAULT CHARACTER SET utf8;
    4342CREATE DATABASE `base2dynamic` DEFAULT CHARACTER SET utf8;
     
    4544GRANT ALL ON `base2`.* TO 'base2user'@'localhost' IDENTIFIED BY 'password';
    4645GRANT ALL ON `base2dynamic`.* TO 'base2user'@'localhost';
    47 
    48 /*For MySql 5.0 only
    49 SET PASSWORD FOR 'base2user'@'localhost' = OLD_PASSWORD('password');
    50 FLUSH PRIVILEGES;*/
  • trunk/misc/sql/createdb.postgres.sql

    r4509 r4637  
    4040*/
    4141CREATE USER "base2user" PASSWORD 'password';
    42 CREATE DATABASE "base2" OWNER "base2user" ENCODING 'UNICODE';
     42CREATE DATABASE "base2" OWNER "base2user" ENCODING 'UTF8';
    4343\c "base2"
    4444CREATE SCHEMA "dynamic" AUTHORIZATION "base2user";
Note: See TracChangeset for help on using the changeset viewer.