Skip to content
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
49 lines (35 sloc) 1.88 KB

Fixing mixed database encodings of Latin1 to UTF8 in OJS

From, with thanks to Alec Smecher for the suggestion.

This assumes the incorrectly encoded database exists (called ojs_latin in this example). As always, make sure you have backups!

Log into your future database host to create a new database with an UTF-8 charset named ojs

$ mysql -h -u USERNAME -pPASSWORD
mysql> CREATE DATABASE `ojs` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

Flush the current database schema on the future host, replacing all CHARSET=latin1 occurrences along the way

mysqldump --column-statistics=0 -h -u USERNAME -pPASSWORD ojs_latin --no-data --skip-set-charset --default-character-set=latin1 \
| sed 's/CHARSET=latin1/CHARSET=utf8/g' \
| mysql -h -u USERNAME -pPASSWORD ojs --default-character-set=utf8

Flush the current database data on the future host

mysqldump --column-statistics=0 -h -u USERNAME -pPASSWORD --no-create-db --no-create-info --skip-set-charset --default-character-set=latin1 ojs_latin \
| mysql -h -u USERNAME -pPASSWORD ojs --default-character-set=utf8


If you receive a warning about the article search tables, you can safely delete the contents of article_search_keyword_list, article_search_object_keywords, and article_search_objects before upgrading – these tables contain the full-text search index and can be re-generated afterwards by running php tools/rebuildSearchIndex.php.

OJS 2:

DELETE FROM article_search_keyword_list;
DELETE FROM article_search_object_keywords;
DELETE FROM article_search_objects;

OJS 3:

DELETE FROM submission_search_keyword_list;
DELETE FROM submission_search_object_keywords;
DELETE FROM submission_search_objects;

If not set, set charset = utf8 in after fixing the database.

You can’t perform that action at this time.