将mediawiki数据库从postgresql转换为mysql/mariadb
为什么要使用mysql/mariadb而不是postgresql?
大多数常用的维护脚本都适用于 PostgreSQL,但一些不太常见的脚本可能会有问题。
PostgreSQL 是 MediaWiki 的好选择吗?
维基百科使用 MariaDB,因此 MediaWiki 在 MariaDB 上比在 PostgreSQL 上得到更多测试。虽然对 PostgreSQL 的支持由志愿者维护,但大多数核心功能都能正常工作。
挑战
为什么不在mediawiki中使用dumpBackup.php脚本? [[2]]
如果您只需要保存 mediawiki 数据和页面修改历史记录,那么最好也是最简单的方法可能是
php maintenance/dumpBackup.php --full --include-files --uploads > /tmp/wiki.xml php maintenance/importDump.php /tmp/wiki.xml
但是,用户帐户、用户贡献、日志等将不会以这种方式迁移。
为什么不使用工具将postgresql数据库转换为mysql?
Mediawiki PostgreSQL 版本与 MySQL 版本非常不同。例如:一些表名不同、字段顺序不同、时间戳格式不同 (pg: '2015-11-01 08:42:31+00', mysql: '20151101084231'),PostgreSQL 中许多允许为 NULL 的字段在 MySQL 中不允许为 NULL。这就是为什么从 PostgreSQL 转储数据并将其导入 MySQL 时会出现问题。
在 https://www.winterrodeln.org/trac/wiki/MediaWikiPostgresqlToMysql 中提到了一个应该将 PostgreSQL 数据库转换为 MySQL 的脚本。然而,在我的情况下,由于上面提到的问题,它没有工作(该脚本写于 2009-01-16)。
Mediawiki 位置
在本例中,mediawiki 文件根目录位于 /var/www/wiki.wikiname.org/htdocs/w
Web 服务器是 lighttpd。/etc/lighttpd/lighttpd.conf 包含以下行
simple-vhost.server-root = "/var/www" simple-vhost.default-host = "wiki.wikiname.org" simple-vhost.document-root = "/htdocs/" url.rewrite-once = ( "^/wiki/([^?]*)(?:\?(.*))?" => "/w/index.php?title=$1&$2", "^/wiki" => "/w/index.php", )
禁止编辑mediawiki直到数据库转换完成
vi /var/www/wiki.wikiname.org/htdocs/w/LocalSettings.php
$wgReadOnly = 'This wiki is currently being upgraded to a newer software version.';
准备用于导入数据到mysql的转储文件
制作postgresql转储
su - postgres pg_dump wikidb > /tmp/wikidb-pg.dump exit
制作临时postgresql数据库,使其看起来像mysql
su - postgres echo "CREATE DATABASE tmpdb ENCODING 'SQL_ASCII' LC_COLLATE='C' LC_CTYPE='C' TEMPLATE=template0;" | psql psql tmpdb < /tmp/wikidb-pg.dump exit
修改postgresql数据库的SQL脚本
为了避免将数据导入 MySQL 时出现问题,我们需要修改 mediawiki PostgreSQL 数据库,使其看起来像 mediawiki MySQL 数据库。基本上,该脚本将使 pg 表中的字段顺序像 MySQL 中一样,并将不允许在 MySQL 中为 NULL 的字段设置为非 NULL 值
/tmp/pg-prepare-for-mysql.sql
/* archive */ CREATE VIEW tmp_view AS select ar_id, ar_namespace, ar_title, ar_text, ar_comment, ar_user, ar_user_text, ar_timestamp, ar_minor_edit, ar_flags, ar_rev_id, ar_text_id, ar_deleted, ar_len, ar_page_id, ar_parent_id, ar_sha1, ar_content_model, ar_content_format FROM archive; SELECT * INTO tmp_table FROM tmp_view; DROP VIEW tmp_view; update tmp_table set ar_text = '' where ar_text is NULL; update tmp_table set ar_comment = '' where ar_comment is NULL; update tmp_table set ar_user = 0 where ar_user is NULL; update tmp_table set ar_flags = '' where ar_flags is NULL; ALTER TABLE archive RENAME TO orig_archive; ALTER TABLE tmp_table RENAME TO archive; /* category */ CREATE VIEW tmp_view AS select cat_id, cat_title, cat_pages, cat_subcats, cat_files FROM category; SELECT * INTO tmp_table FROM tmp_view; DROP VIEW tmp_view; ALTER TABLE category RENAME TO orig_category; ALTER TABLE tmp_table RENAME TO category; /* categorylinks */ CREATE VIEW tmp_view AS select cl_from, cl_to, cl_sortkey, cl_sortkey_prefix, cl_timestamp, cl_collation, cl_type FROM categorylinks; SELECT * INTO tmp_table FROM tmp_view; DROP VIEW tmp_view; update tmp_table set cl_sortkey = '' where cl_sortkey is NULL; ALTER TABLE categorylinks RENAME TO orig_categorylinks; ALTER TABLE tmp_table RENAME TO categorylinks; /* change_tag (OK) */ /* externallinks */ CREATE VIEW tmp_view AS select el_id, el_from, el_to, el_index FROM externallinks; SELECT * INTO tmp_table FROM tmp_view; DROP VIEW tmp_view; ALTER TABLE externallinks RENAME TO orig_externallinks; ALTER TABLE tmp_table RENAME TO externallinks; /* filearchive (OK) */ /* image */ CREATE VIEW tmp_view AS select img_name, img_size, img_width, img_height, img_metadata, img_bits, img_media_type, img_major_mime, img_minor_mime, img_description, img_user, img_user_text, img_timestamp, img_sha1 FROM image; SELECT * INTO tmp_table FROM tmp_view; DROP VIEW tmp_view; update tmp_table set img_bits = 0 where img_bits is NULL; update tmp_table set img_major_mime = '' where img_major_mime is NULL; update tmp_table set img_minor_mime = '' where img_minor_mime is NULL; ALTER TABLE image RENAME TO orig_image; ALTER TABLE tmp_table RENAME TO image; /* imagelinks */ CREATE VIEW tmp_view AS select il_from, il_from_namespace, il_to FROM imagelinks; SELECT * INTO tmp_table FROM tmp_view; DROP VIEW tmp_view; ALTER TABLE imagelinks RENAME TO orig_imagelinks; ALTER TABLE tmp_table RENAME TO imagelinks; /* interwiki */ CREATE VIEW tmp_view AS select iw_prefix, iw_url, iw_api, iw_wikiid, iw_local, iw_trans FROM interwiki; SELECT * INTO tmp_table FROM tmp_view; DROP VIEW tmp_view; ALTER TABLE interwiki RENAME TO orig_interwiki; ALTER TABLE tmp_table RENAME TO interwiki; /* ipblocks */ CREATE VIEW tmp_view AS select ipb_id, ipb_address, ipb_user, ipb_by, ipb_by_text, ipb_reason, ipb_timestamp, ipb_auto, ipb_anon_only, ipb_create_account, ipb_enable_autoblock, ipb_expiry, ipb_range_start, ipb_range_end, ipb_deleted, ipb_block_email, ipb_allow_usertalk, ipb_parent_block_id FROM ipblocks; SELECT * INTO tmp_table FROM tmp_view; DROP VIEW tmp_view; update tmp_table set ipb_address = '' where ipb_address is NULL; update tmp_table set ipb_user = 0 where ipb_user is NULL; update tmp_table set ipb_range_start = '' where ipb_range_start is NULL; update tmp_table set ipb_range_end = '' where ipb_range_end is NULL; ALTER TABLE ipblocks RENAME TO orig_ipblocks; ALTER TABLE tmp_table RENAME TO ipblocks; /* iwlinks (OK) */ /* job */ CREATE VIEW tmp_view AS select job_id, job_cmd, job_namespace, job_title, job_timestamp, job_params, job_random, job_attempts, job_token, job_token_timestamp, job_sha1 FROM job; SELECT * INTO tmp_table FROM tmp_view; DROP VIEW tmp_view; ALTER TABLE job RENAME TO orig_job; ALTER TABLE tmp_table RENAME TO job; /* l10n_cache (OK) */ /* langlinks */ CREATE VIEW tmp_view AS select ll_from, ll_lang, ll_title FROM langlinks; SELECT * INTO tmp_table FROM tmp_view; DROP VIEW tmp_view; update tmp_table set ll_lang = '' where ll_lang is NULL; update tmp_table set ll_title = '' where ll_title is NULL; ALTER TABLE langlinks RENAME TO orig_langlinks; ALTER TABLE tmp_table RENAME TO langlinks; /* logging */ CREATE VIEW tmp_view AS select log_id, log_type, log_action, log_timestamp, log_user, log_user_text, log_namespace, log_title, log_page, log_comment, log_params, log_deleted FROM logging; SELECT * INTO tmp_table FROM tmp_view; DROP VIEW tmp_view; update tmp_table set log_user = 0 where log_user is NULL; update tmp_table set log_comment = '' where log_comment is NULL; update tmp_table set log_params = '' where log_params is NULL; ALTER TABLE logging RENAME TO orig_logging; ALTER TABLE tmp_table RENAME TO logging; /* log_search (OK) */ /* module_deps (OK) */ /* msg_resource (OK) */ /* msg_resource_links (OK) */ /* objectcache */ CREATE VIEW tmp_view AS select keyname, value, exptime FROM objectcache; SELECT * INTO tmp_table FROM tmp_view; DROP VIEW tmp_view; update tmp_table set keyname = '' where keyname is NULL; ALTER TABLE objectcache RENAME TO orig_objectcache; ALTER TABLE tmp_table RENAME TO objectcache; /* oldimage */ CREATE VIEW tmp_view AS select oi_name, oi_archive_name, oi_size, oi_width, oi_height, oi_bits, oi_description, oi_user, oi_user_text, oi_timestamp, oi_metadata, oi_media_type, oi_major_mime, oi_minor_mime, oi_deleted, oi_sha1 FROM oldimage; SELECT * INTO tmp_table FROM tmp_view; DROP VIEW tmp_view; update tmp_table set oi_bits = 0 where oi_bits is NULL; update tmp_table set oi_description = '' where oi_description is NULL; update tmp_table set oi_user = 0 where oi_user is NULL; update tmp_table set oi_major_mime = '' where oi_major_mime is NULL; update tmp_table set oi_minor_mime = '' where oi_minor_mime is NULL; ALTER TABLE oldimage RENAME TO orig_oldimage; ALTER TABLE tmp_table RENAME TO oldimage; /* page */ CREATE VIEW tmp_view AS select page_id, page_namespace, page_title, page_restrictions, page_is_redirect, page_is_new, page_random, page_touched, page_links_updated, page_latest, page_len, page_content_model, page_lang FROM page; SELECT * INTO tmp_table FROM tmp_view; DROP VIEW tmp_view; update tmp_table set page_restrictions = '' where page_restrictions is NULL; /*update tmp_table set page_touched = '' where page_touched is NULL;*/ ALTER TABLE page RENAME TO orig_page; ALTER TABLE tmp_table RENAME TO page; /* pagelinks */ CREATE VIEW tmp_view AS select pl_from, pl_from_namespace, pl_namespace, pl_title FROM pagelinks; SELECT * INTO tmp_table FROM tmp_view; DROP VIEW tmp_view; ALTER TABLE pagelinks RENAME TO orig_pagelinks; ALTER TABLE tmp_table RENAME TO pagelinks; /* page_props (OK) */ /* page_restrictions */ CREATE VIEW tmp_view AS select pr_id, pr_page, pr_type, pr_level, pr_cascade, pr_user, pr_expiry FROM page_restrictions; SELECT * INTO tmp_table FROM tmp_view; DROP VIEW tmp_view; ALTER TABLE page_restrictions RENAME TO orig_page_restrictions; ALTER TABLE tmp_table RENAME TO page_restrictions; /* protected_titles */ CREATE VIEW tmp_view AS select pt_namespace, pt_title, pt_user, pt_reason, pt_timestamp, pt_expiry, pt_create_perm FROM protected_titles; SELECT * INTO tmp_table FROM tmp_view; DROP VIEW tmp_view; update tmp_table set pt_user = 0 where pt_user is NULL; /*update tmp_table set pt_expiry = '' where pt_expiry is NULL;*/ ALTER TABLE protected_titles RENAME TO orig_protected_titles; ALTER TABLE tmp_table RENAME TO protected_titles; /* querycache (OK) */ /* querycachetwo (OK) */ /* querycache_info */ CREATE VIEW tmp_view AS select qci_type, qci_timestamp FROM querycache_info; SELECT * INTO tmp_table FROM tmp_view; DROP VIEW tmp_view; update tmp_table set qci_type = '' where qci_type is NULL; /* update tmp_table set qci_timestamp = '' where qci_timestamp is NULL; */ ALTER TABLE querycache_info RENAME TO orig_querycache_info; ALTER TABLE tmp_table RENAME TO querycache_info; /* recentchanges (rc_cur_time was removed in 1.24wmf6) */ CREATE VIEW tmp_view AS select rc_id, rc_timestamp, rc_user, rc_user_text, rc_namespace, rc_title, rc_comment, rc_minor, rc_bot, rc_new, rc_cur_id, rc_this_oldid, rc_last_oldid, rc_type, rc_source, rc_patrolled, rc_ip, rc_old_len, rc_new_len, rc_deleted, rc_logid, rc_log_type, rc_log_action, rc_params FROM recentchanges; SELECT * INTO tmp_table FROM tmp_view; DROP VIEW tmp_view; update tmp_table set rc_user = 0 where rc_user is NULL; update tmp_table set rc_comment = '' where rc_comment is NULL; update tmp_table set rc_cur_id = 0 where rc_cur_id is NULL; /* update tmp_table set rc_ip = '' where rc_ip is NULL; */ ALTER TABLE recentchanges RENAME TO orig_recentchanges; ALTER TABLE tmp_table RENAME TO recentchanges; /* redirect (OK) */ /* revision */ CREATE VIEW tmp_view AS select rev_id, rev_page, rev_text_id, rev_comment, rev_user, rev_user_text, rev_timestamp, rev_minor_edit, rev_deleted, rev_len, rev_parent_id, rev_sha1, rev_content_model, rev_content_format FROM revision; SELECT * INTO tmp_table FROM tmp_view; DROP VIEW tmp_view; update tmp_table set rev_page = 0 where rev_page is NULL; update tmp_table set rev_text_id = 0 where rev_text_id is NULL; update tmp_table set rev_comment = '' where rev_comment is NULL; ALTER TABLE revision RENAME TO orig_revision; ALTER TABLE tmp_table RENAME TO revision; /* searchindex (does not exists in pg) */ /* sites (OK) */ /* site_identifiers (OK) */ /* site_stats */ CREATE VIEW tmp_view AS select ss_row_id, ss_total_edits, ss_good_articles, ss_total_pages, ss_users, ss_active_users, ss_images FROM site_stats; SELECT * INTO tmp_table FROM tmp_view; DROP VIEW tmp_view; ALTER TABLE site_stats RENAME TO orig_site_stats; ALTER TABLE tmp_table RENAME TO site_stats; /* tag_summary (OK) */ /* templatelinks */ CREATE VIEW tmp_view AS select tl_from, tl_from_namespace, tl_namespace, tl_title FROM templatelinks; SELECT * INTO tmp_table FROM tmp_view; DROP VIEW tmp_view; ALTER TABLE templatelinks RENAME TO orig_templatelinks; ALTER TABLE tmp_table RENAME TO templatelinks; CREATE VIEW tmp_view AS select old_id, old_text, old_flags FROM pagecontent; SELECT * INTO tmp_table FROM tmp_view; DROP VIEW tmp_view; update tmp_table set old_text = '' where old_text is NULL; update tmp_table set old_flags = '' where old_flags is NULL; ALTER TABLE pagecontent RENAME TO orig_pagecontent; ALTER TABLE tmp_table RENAME TO pagecontent; /* transcache (OK) */ /* updatelog (OK) */ /* uploadstash */ CREATE VIEW tmp_view AS select us_id, us_user, us_key, us_orig_path, us_path, us_source_type, us_timestamp, us_status, us_chunk_inx, us_props, us_size, us_sha1, us_mime, us_media_type, us_image_width, us_image_height, us_image_bits FROM uploadstash; SELECT * INTO tmp_table FROM tmp_view; DROP VIEW tmp_view; update tmp_table set us_user = 0 where us_user is NULL; update tmp_table set us_key = '' where us_key is NULL; update tmp_table set us_orig_path = '' where us_orig_path is NULL; update tmp_table set us_path = '' where us_path is NULL; /* update tmp_table set us_timestamp = '' where us_timestamp is NULL; */ update tmp_table set us_status = '' where us_status is NULL; update tmp_table set us_size = 0 where us_size is NULL; update tmp_table set us_sha1 = '' where us_sha1 is NULL; ALTER TABLE uploadstash RENAME TO orig_uploadstash; ALTER TABLE tmp_table RENAME TO uploadstash; /* user (in pg it is named mwuser)*/ CREATE VIEW tmp_view AS select user_id, user_name, user_real_name, user_password, user_newpassword, user_newpass_time, user_email, user_touched, user_token, user_email_authenticated, user_email_token, user_email_token_expires, user_registration, user_editcount, user_password_expires FROM mwuser; SELECT * INTO tmp_table FROM tmp_view; DROP VIEW tmp_view; update tmp_table set user_real_name = '' where user_real_name is NULL; update tmp_table set user_password = '' where user_password is NULL; update tmp_table set user_newpassword = '' where user_newpassword is NULL; update tmp_table set user_token = '' where user_token is NULL; update tmp_table set user_email = '' where user_email is NULL; /* update tmp_table set user_touched = '' where user_touched is NULL; */ delete from tmp_table where user_id = 0; ALTER TABLE mwuser RENAME TO orig_mwuser; ALTER TABLE tmp_table RENAME TO mwuser; /* it cannot be named 'user', like in mysql */ /* user_former_groups */ CREATE VIEW tmp_view AS select ufg_user, ufg_group FROM user_former_groups; SELECT * INTO tmp_table FROM tmp_view; DROP VIEW tmp_view; update tmp_table set ufg_user = 0 where ufg_user is NULL; ALTER TABLE user_former_groups RENAME TO orig_user_former_groups; ALTER TABLE tmp_table RENAME TO user_former_groups; /* user_groups */ CREATE VIEW tmp_view AS select ug_user, ug_group FROM user_groups; SELECT * INTO tmp_table FROM tmp_view; DROP VIEW tmp_view; update tmp_table set ug_user = 0 where ug_user is NULL; ALTER TABLE user_groups RENAME TO orig_user_groups; ALTER TABLE tmp_table RENAME TO user_groups; /* user_newtalk */ CREATE VIEW tmp_view AS select user_id, user_ip, user_last_timestamp FROM user_newtalk; SELECT * INTO tmp_table FROM tmp_view; DROP VIEW tmp_view; update tmp_table set user_ip = '' where user_ip is NULL; ALTER TABLE user_newtalk RENAME TO orig_user_newtalk; ALTER TABLE tmp_table RENAME TO user_newtalk; /* user_properties */ CREATE VIEW tmp_view AS select up_user, up_property, up_value FROM user_properties; SELECT * INTO tmp_table FROM tmp_view; DROP VIEW tmp_view; update tmp_table set up_user = 0 where up_user is NULL; ALTER TABLE user_properties RENAME TO orig_user_properties; ALTER TABLE tmp_table RENAME TO user_properties; /* valid_tag (OK) */ /* watchlist (OK) */ /* external_user (not needed) */ ALTER TABLE external_user RENAME TO orig_external_user; /* hitcounter (removed in MediaWiki 1.25) */ ALTER TABLE hitcounter RENAME TO orig_hitcounter; /* mediawiki_version ('Nobody actually uses it anymore, it just gets silently updated (and only for Postgres at that)') */ ALTER TABLE mediawiki_version RENAME TO orig_mediawiki_version; /* profiling ('It's only used in an obscure debugging mode.') */ ALTER TABLE profiling RENAME TO orig_profiling; /* trackbacks (This feature was removed completely in version MediaWiki 1.19.) */ ALTER TABLE trackbacks RENAME TO orig_trackbacks;
su - postgres psql tmpdb < /tmp/pg-prepare-for-mysql.sql exit
制作用于mysql导入的转储文件
su - postgres mkdir /tmp/wikidb-pg-dump psql -d wikidb -c "SELECT table_schema || '.' || table_name FROM information_schema.tables WHERE table_type = 'BASE TABLE' AND table_schema NOT IN ('pg_catalog', 'information_schema');" > /tmp/t cat /tmp/t | grep mediawiki | sed 's/ mediawiki.//g' | sort > /tmp/pg-tables.txt for t in `cat /tmp/pg-tables.txt`; do echo "dumping $t"; pg_dump -d tmpdb --data-only --inserts -t mediawiki.$t > /tmp/wikidb-pg-dump/$t.sql; done exit
修改转储文件
应删除 PostgreSQL 特定的 SQL
cd /tmp/wikidb-pg-dump for f in *.sql; do sed -i 's/^SET statement_timeout = 0;$//g' $f; done for f in *.sql; do sed -i 's/^SET lock_timeout = 0;$//g' $f; done for f in *.sql; do sed -i "s/^SET client_encoding = 'SQL_ASCII';$//g" $f; done for f in *.sql; do sed -i 's/^SET standard_conforming_strings = on;$//g' $f; done for f in *.sql; do sed -i 's/^SET check_function_bodies = false;$//g' $f; done for f in *.sql; do sed -i 's/^SET client_min_messages = warning;$//g' $f; done for f in *.sql; do sed -i 's/^SET search_path = mediawiki, pg_catalog;$//g' $f; done for f in *.sql; do sed -i "s/^SELECT pg_catalog.setval('filearchive_fa_id_seq', 25, true);$//g" $f; done
PostgreSQL 表 mwuser 对应于 MySQL 表 user
for f in *.sql; do sed -i "s/^INSERT INTO mwuser VALUES/INSERT INTO user VALUES/g" $f; done
PostgreSQL 表 pagecontent 对应于 MySQL 表 text
for f in *.sql; do sed -i "s/^INSERT INTO pagecontent VALUES/INSERT INTO text VALUES/g" $f; done
反斜杠应替换为双反斜杠
for f in *.sql; do sed -i 's/\\/\\\\/g' $f; done
PostgreSQL 中的时间戳格式与 MySQL 不同 (pg: '2015-10-31 10:10:10+00', mysql: '20151031101010')。所有时间戳都应转换以避免类似这样的错误
... Language::sprintfDate: 时间戳应该是一个数字
for f in *.sql; do sed -i "s/'\([0-9][0-9][0-9][0-9]\)-\([0-9][0-9]\)-\([0-9][0-9]\) \([0-9][0-9]\):\([0-9][0-9]\):\([0-9][0-9]\)[+-][0-9][0-9]'/'\1\2\3\4\5\6'/g" $f; done
在 PostgreSQL 中,ipblocks 表可能包含具有重复字段 ipb_address 的记录。MySQL 要求 ipb_address 字段是唯一的。手动检查 ipblocks.sql 文件。删除具有重复字段 ipb_address 的记录,以防止类似这样的错误
# ERROR 1062 (23000) at line 152: Duplicate entry 'xxxxxx-0-0-0' for key 'ipb_address'
vi ipblocks.sql
更改mysql root密码,为mediawiki创建用户
mysql -u root SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpassword'); SET PASSWORD FOR 'root'@'127.0.0.1' = PASSWORD('newpassword'); SET PASSWORD FOR 'root'@'::1' = PASSWORD('newpassword'); FLUSH PRIVILEGES; CREATE USER 'wikiuser'@'localhost' IDENTIFIED BY 'wikiuserpassword'; GRANT ALL PRIVILEGES ON *.* TO 'wikiuser'@'localhost' WITH GRANT OPTION; CREATE USER 'wikiuser'@'%' IDENTIFIED BY 'wikiuserpassword'; GRANT ALL PRIVILEGES ON *.* TO 'wikiuser'@'%' WITH GRANT OPTION; exit
设置新的mediawiki
cd /var/www/wiki.wikiname.org/htdocs wget https://releases.wikimedia.org/mediawiki/1.25/mediawiki-1.25.3.tar.gz tar zxf mediawiki-1.25.3.tar.gz mv mediawiki-1.25.3 w rm mediawiki-1.25.3.tar.gz
vi index.php
<?php header('Location: /wiki'); ?>
在浏览器中打开您的 wiki https://wiki.wikiname.org,完成设置过程(数据库类型:mysql,引擎:innodb,字符集:binary)
将设置过程生成的 LocalSettings.php 文件与旧的 mediawiki LocalSettings.php 文件进行比较
从旧的 LocalSettings.php 中获取所需的设置
将新的 LocalSettings.php 复制到 mediawiki 目录 /var/www/wiki.wikiname.org/htdocs/w
从旧的 mediawiki 复制所需的文件 (images/*, extensions/..., resources/...)
cd /var/www/wiki.wikiname.org/htdocs/w find . -type d > /tmp/d while read d; do chmod 755 "$d"; done < /tmp/d find . -type f > /tmp/f while read f; do chmod 644 "$f"; done < /tmp/f chown -R lighttpd:lighttpd . cd /var/www/wiki.wikiname.org/htdocs/w php maintenance/update.php # 这将激活扩展并在 MySQL 数据库中创建所需的表
导入前清除mysql表
mysql wikidb -uUSERNAME -pPASSWORD --default-character-set=utf8 -Bse 'show tables;' > /tmp/t for t in `cat /tmp/t`; do echo "TRUNCATE $t;"; done >/tmp/mysql-clear-tables.sql mysql wikidb -uUSERNAME -pPASSWORD --default-character-set=utf8 < /tmp/mysql-clear-tables.sql
将数据导入mysql
for t in `cat /tmp/pg-tables.txt`; do echo "importing $t"; mysql wikidb -uUSERNAME -pPASSWORD --default-character-set=utf8 < /path/to/wikidb-pg-dump/$t.sql; done
运行维护脚本
php maintenance/update.php php maintenance/rebuildrecentchanges.php php maintenance/rebuildtextindex.php
重新生成缓存
l10n_cache 表中的旧缓存可能会导致问题。可以删除并重新生成。
echo "TRUNCATE l10n_cache;" | mysql wikidb -uUSERNAME -pPASSWORD --default-character-set=utf8 cd /var/www/wiki.wikiname.org/htdocs/w php maintenance/rebuildLocalisationCache.php