Truncate mediawiki
I'm working with the mediawiki API ( e.g. http://en.wikiped开发者_JAVA百科ia.org/w/api.php) and I would like to be able to 'truncate' the mysql tables in order to reset the local installation while keeping some tables (users, ?...). What would be the SQL queries ?
I would say: tuncate all the tables but ${PREFIX}_user and update ${PREFIX}_user set user_editcount=0 ?
Any other(safer) suggestion ?
The correct answer was posted on the MediaWiki mailing list: see http://lists.wikimedia.org/pipermail/mediawiki-l/2009-October/032322.html
According to that post, it is probably ok to truncate user_newtalk
, page
, revision
, text
,
archive
, pagelinks
, templatelinks
, imagelinks
, categorylinks
, category
, externallinks
, langlinks
, hitcounter
, watchlist
, image
, oldimage
, filearchive
, recentchanges
, searchindex
, interwiki
, querycache
, objectcache
, log_search
, trackbacks
, job
, querycache_info
, redirect
, querycachetwo
, page_restrictions
, protected_titles
, page_props
, change_tags
, tag_summary
, valid_tag
, l10n_cache
.
On more recent versions, add msg_resource
and msg_resource_list
to that list, to truncate message related caches.
Also: Remember to delete the files at the image folder, if truncating the image table. Otherwise they will be out of sync, and you might have trouble uploading some images.
get list of tables from your database:
echo "show tables;" | mysql -u user_name -p db_name > tables
determine which tables you want to truncate, then create an sql script
TRUNCATE TABLE a;
TRUNCATE TABLE b;
update <prefix>user set user_editcount=0;
then run it through the client:
mysql -u user_name -p database_name < truncate-all.sql
精彩评论