creation of new webwork course failed with 2.7

creation of new webwork course failed with 2.7

by Marc BUFFAT -
Number of replies: 4
I have upgraded to Webwork to 2.7 since 6 months, and everything is running
Yesterday however I have tried to create a new course using the admin interface without success. Thus I try using the command line, and I got the following error message (at and of the post).
It seems that addcourse create an incomplete data-base structure for the new course: courstest
courstest_permission, and courstest_setting are missing, and then
the script stops with an error.
Using mysql inline, I was able to build the correct database structure and then
use the course, but I wanted determine the error
I am running Webword 2.7 with moodle 2.2 on an uptodate ubuntu 2.10 box

../webwork2/bin/addcourse courstest --db-layout=sql_single --users=adminClasslist.lst --professors=admin
addcourse: WeBWorK root directory set to /opt/webwork/webwork2
addcourse: WeBWorK server is starting
addcourse: WeBWorK root directory set to /opt/webwork/webwork2 in webwork2/conf/webwork.apache2-config
addcourse: The following locations and urls are set in webwork2/conf/site.conf
addcourse: PG root directory set to /opt/webwork/pg
addcourse: WeBWorK server userID is www-data
addcourse: WeBWorK server groupID is www-data
addcourse: The webwork url on this site is
Use of uninitialized value in join or string at /opt/webwork/webwork2/lib/WeBWorK/DB/Schema/NewSQL/ line 814.
DBD::mysql::db do failed: Specified key was too long; max key length is 1000 bytes





In reply to Marc BUFFAT

Re: creation of new webwork course failed with 2.7

by Danny Glin -
What version of MySQL are you running?

Can you run the following mysql command on one of the tables that succeeded, and one that you created manually:
mysql> show table status where Name='name_of_table';

This will tell you which database engine is being used (MyISAM or InnoDB probably), and which character set.  Based on some initial research, each of these can affect key length restrictions.

In reply to Danny Glin

Re: creation of new webwork course failed with 2.7

by Marc BUFFAT -
Your are right Danny
it is a database engine problem. I run your myslq command, and
it turns out that the table are created using the myisam engine
(I have changed mysql conf following the webwork WIKI
which states to change the default engine from innodb to mysisam
As I am french, I am using UTF8 encoding, and there is a problem with myisam
and ut8 encoding for certain tables.
I have now changed the default encoding of mysql in my.cnf
default-storage-engine = innodb
and know the creation of new course works (using innodb engine)

In conclusion, for foreign language, don't use myisam with webwork but only innodb (may be it should be pointed out in the documentation)

Thanks again


ubuntu 12.04 64 bits, webwork 2.7
mysql --version
mysql Ver 14.14 Distrib 5.5.34, for debian-linux-gnu (x86_64) using readline 6.2

In reply to Marc BUFFAT

Re: creation of new webwork course failed with 2.7

by Arnold Pizer -
Thanks Marc,

In the documentation, I now have:

Now we change MySQL's default engine. The default engine is InnoDB as of MySQL 5.5.5 (MyISAM before 5.5.5) but (at least on some hardware) InnoDB seems to be 50-100 times slower than MyISAM. So we will change the default MySQL engine from InnoDB to MyISAM. Note that this change only applies to new tables, tables already constructed will continue to use InnoDB. But we haven't created any WeBWorK tables so we don't have to change the engine for any existing tables. Note: There is a report of a problem using MyISAM by a French speaking professor who changed MySQL's default character set to utf8 (see If you change MySQL's default character set, you should research what is the best engine to use.

In reply to Arnold Pizer

Re: creation of new webwork course failed with 2.7

by Danny Glin -
After a bit of googling, it looks like utf8 requires 3 bytes of storage per character, as opposed to the other character sets only requiring 1 byte.  This puts some of the indexes over the 1000 byte limit set by mysql for MyISAM tables.

We should be able to solve this by decreasing the index size in tables created by WeBWorK.  A quick look at the code indicates that it is keying on the first 255 characters of text fields.  My recollection is that there isn't a table with more than 3 columns making up an index, meaning that if we reduce the value from 255 to 100, it should work even for utf8 (3 fields * 100 characters * (max) 3 bytes per character = 900 bytes).  Of course this means that it would require key fields to be unique within the first 100 characters, which in my experience wouldn't be an issue.