Upgrade from 2.4 to 2.5 problem

Upgrade from 2.4 to 2.5 problem

by Richard Ayuyang -
Number of replies: 18

Hello! I'm having trouble upgrading our site from Moodle 2.4+ to 2.5. The unicode test gives me headache. Our MySQL database and all its tables are all in utf8_unicode_ci format and yet the installation or upgrade won't proceed. It keeps on saying the unicode must be installed.

I have no problems upgrading from 1.9 to 2.4 without character set issue until the version 2.5. Any advice/s to this?

Average of ratings: -
In reply to Richard Ayuyang

Re: Upgrade from 2.4 to 2.5 problem

by Michelle Ervin -

I'm having this same problem...haven't figured it out....

In reply to Richard Ayuyang

Re: Upgrade from 2.4 to 2.5 problem

by Ken Task -
Picture of Particularly helpful Moodlers

Is the character set of the DB also utf8?  What does Site Admin menu -> Server -> Environment show?

In whatever you have to interact with the DB, try these two queries on the database for Moodle:

show variables like"character_set_database";
show variables like"collation_database";

'spirit of sharing', Ken

 

In reply to Ken Task

Re: Upgrade from 2.4 to 2.5 problem

by Michelle Ervin -

Site Admin menu -> Server -> Environment

 

 

 

For this:

In whatever you have to interact with the DB, try these two queries on the database for Moodle:

show variables like"character_set_database";
show variables like"collation_database";

I'm not sure what you mean.....In my db, it shows this:

I'm guessing that the problem lies in that every table is not in utf8....but in phpMyAdmin,  under "operations", I have selected the "utf8_unicode_ci".  That shows up at the bottom...but it didn't change the tables that exist.  I've been going crazy all day trying to figure out how to change the existing tables.  The only way I have figured out is to INDIVIDUALLY change each table, which will take me DAYS!  I can't believe that if this is the problem, there isn't some way that moodle hasn't come up with a way to change them all.  2.4 supposedly needed utf, and it works ok....I don't understand why upgrading to 2.5 isn't accepting it.....

 

 

In reply to Michelle Ervin

Re: Upgrade from 2.4 to 2.5 problem

by Michelle Ervin -

Pictures didn't show up on the previous post...

 

Attachment just48.justhost.com   localhost   ellteac1_mdle2   phpMyAdmin 3.4.11.1.png
In reply to Michelle Ervin

Re: Upgrade from 2.4 to 2.5 problem

by Guillermo Madero -

Michelle,

Not only your tables are using the latin1 character set/latin1_swedish_ci collation, but they are using the MyISAM engine instead of the InnoDB engine.

So you are currently using Moodle 2.4?

Assuming your Moodle is installed in a directory under the main site and it has the default name (i.e. your-site.com/moodle), then under the moodle/admin/cli path you'll find two PHP scripts that can help you fix these two issues: mysql_collation.php and mysql_engine.php. They need to be run from the command line:

http://docs.moodle.org/25/en/Administration_via_command_line

 

At the following post you can find more info about how to fix the character set and collation issue by hand:

https://moodle.org/mod/forum/discuss.php?d=235882#p1024633

To update the database engine you need to use the following SQL statement:

ALTER TABLE table_name ENGINE=InnoDB;

In reply to Guillermo Madero

Re: Upgrade from 2.4 to 2.5 problem

by Brian Yare -

I also get a notification that I should convert to InnoDB. I do not have command line access on my shared server using MySQLi.

Is there an easy way to do the conversion?

In reply to Brian Yare

Re: Upgrade from 2.4 to 2.5 problem

by Guillermo Madero -

Hi Brian,

Assuming you have phpMyAdmin (or some other other way to work with your database) you would start by selecting your Moodle database and then execute the following SQL statement:

SHOW TABLES;

This will generate a list of the tables in the database. You would then need to copy this list and paste it in your text editor, like so: 

mdl_config
mdl_course
mdl_files
  etc.

Then you only have to modify each row to add the SQL keywords, like so:

ALTER TABLE mdl_config  ENGINE=InnoDB;
ALTER TABLE mdl_course ENGINE=InnoDB;
ALTER TABLE mdl_files ENGINE=InnoDB;
   etc.

Finally, put your site in maintenance mode, copy the SQL statements, go to the SQL command window of your phpMyAdmin, paste them and run them. Once the process finishes, set back your site to normal mode.

 

Average of ratings: Useful (2)
In reply to Guillermo Madero

Re: Upgrade from 2.4 to 2.5 problem

by Brian Yare -

Thank you, Guillermo.

That appears to have worked. But for the information of others I offer the observation that the resulting SQL string timed out on my server - I had to split it into two halves in order for it to complete.

It only took about 10 minutes all in, including taking a backup of the old database.

The "notification" about InnoDB has now gone away.

Good job.

In reply to Brian Yare

Re: Upgrade from 2.4 to 2.5 problem

by Ken Task -
Picture of Particularly helpful Moodlers

First, know/learn how to backup the DB and restore it from SQL file.   Download the DB's sql dump and archive.

There is, but risky ... do a mysql dump of the DB to an sql file.

Download sql file - work with a copy of that file.

In a text editor that can open what might be a large file, first search for "ENGINE" to see what shows.  If it finds ENGINE=MyISAM.  There's your next search term.  Replace with ENGINE=Innodb ... be VERY exacting ... close doesn't count!

On the server, dump all the tables in the DB.  Then import the edited .sql file with your ENGINE edits.

'spirit of sharing', Ken

In reply to Guillermo Madero

Re: Upgrade from 2.4 to 2.5 problem

by Michelle Ervin -

I also am using a shared server and don't have access to the command line.....

 

And I'm also wondering how to make sure that THAT db is the one that I'm using.  I have like 4 different moodle databases when I look in phpMyadmin...I'm guessing that the one I made a screenshot of is the one because it's the largest.  One is empty, two are 40.74 megs and that one in the screen shot is 403 megs.

Anyway.....yes, I'm running 2.4....I updated it last summer with no problems.  I'd like to update to 2.5 before classes start on Saturday, but I've been at this for 5 or 6 hours today...I just can't fathom having to go through each individual table and change them.  I have over 300 tables.  The link you referred to about manually changing the tables I've seen...it still requires me to change each individual table separately.  300 of them.  Is there no other way???  

 

Michelle

In reply to Michelle Ervin

Re: Upgrade from 2.4 to 2.5 problem

by Guillermo Madero -

Hi Michelle,

You then need to fix manually as recommended.

I sincerely doubt that the screenshot is the one (of the db currently being used). Anyway, to determine what database is being used:

1. Open the config.php file located in your moodle installation directory (usually "moodle", unless you renamed it).

2. Look for the $CFG->dbname directive, it will look like:

$CFG->dbname = 'the-moodle-database-name';

 

If you can't use the command line, then you have to do it by hand. Here is where having, and knowing how to use, a good text editor comes in handy. For example, once I get (with the two queries I posted) the list of tables and/or columns that need to be updated, I paste them into the editor and then I create a macro to update each row. This usually doesn't take but a few minutes. Then I copy everything and paste it in the SQL window of phpMyAdmin, and execute it. All this process really doesn't take that long.

I do understand, however, that this is fairly easy for me because I'm more into the administrative aspect of Moodle, more than anything else. I can help you but I would need you to run each of the aforementioned queries and copy each set of results into a text file; create a zip with both text files and then post it here as an attachment. I'll update the files so you can just copy and paste the SQL statements into your phpMyAdmin SQL command window and execute them.

So, the first text file should have something like:

table_schema  table_name  table_character_set  table_collation
aaa  bbb  ccc  ddd
aaa  bbb  ccc  ddd

and the second one, something like:

table_schema  table_name  column_name  column_character_set  column_collation  data_type  column_type
aaa bbb  ccc  ddd  eee  fff  ggg
aaa bbb  ccc  ddd  eee  fff  ggg

Cheers!

In reply to Guillermo Madero

Re: Upgrade from 2.4 to 2.5 problem

by Michelle Ervin -

Hi,

Thank you so much!  I'm going to try and do it myself some time this week hopefully.  I'm first going to try it on one of those databases that are not being used.....If I just can't figure it out, I'll enlist your expertise. smile  I'm just too tired to continue today.  The site currently works, so if all else...I'll just keep using what I have until I have another 5 hours to work on it. =P

I have also emailed my host to see if there is any way to run that command line script....praying.....

 

Thank you again!  And I'll be back to let you know what happens. smile

 

Michelle

In reply to Guillermo Madero

Re: Upgrade from 2.4 to 2.5 problem

by Michelle Ervin -

Alright...trying to do it by hand.....I've done the InnoDB successfully. Now, when I try to put all 300-some table changes like such:

ALTER TABLE mdl_assignment DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci
ALTER TABLE mdl_assignment_submissions DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci
ALTER TABLE mdl_assignsubmission_file DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci

into the query:

 

 

I get this error:

If I do each one individually, it goes through.  What am I doing wrong? Is there no way to do all of them at once??? I have over 300 tables.....

 

thanks!

Michelle

In reply to Michelle Ervin

Re: Upgrade from 2.4 to 2.5 problem

by Guillermo Madero -

Hi Michelle,

The screenshot shows the basic steps at the phpMyAdmin to get the results from the two queries.

1. Paste the SELECT SQL statement into the SQL command window and click on the Go button.

2. Once the query finishes and lists the results, click on the Print view (with full texts) link near the bottom of the screen.

3. The SQL Result page displayed. Copy this info, paste into a text file (you can use Notepad, or any other text editor) and save it.

Repeat these steps with the second query.

Attachment pma-sql-report.jpg
In reply to Guillermo Madero

Re: Upgrade from 2.4 to 2.5 problem

by Michelle Ervin -

Hi Guillermo,

I just wanted to let you know that I didn't forget! I just wasn't able to get to it before the semester started...and the semester just ended, so I'm going be working on it this week....I will run the queries and post here within a few days.....

 

Thank you SO much!!

Michelle

In reply to Michelle Ervin

Re: Upgrade from 2.4 to 2.5 problem

by Michelle Ervin -

Ok...so I just figured out that I need a semicolon after each line....

So now I'm going through and changing all as you posted before...I will let you know if it all works....

 

ugh...

Michelle

In reply to Guillermo Madero

Re: Upgrade from 2.4 to 2.5 problem

by Michelle Ervin -

Hi again,

So I found out I have a command line....so I went into the command line and tried to run the script as discussed in the moodle doc you linked....but I don't have access to sudo.  It says:

unable to stat /etc/sudoers: No such file or directory
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin

 So I tried to just go into the command line and run the php and it says "permission denied"

Any ideas???

thanks

Michelle