Manual:Sql.php

From mediawiki.org
This page is a translated version of the page Manual:Sql.php and the translation is 64% complete.
MediaWiki バージョン:
1.10

警告 警告: MediaWiki 1.28以降、sql.phpには副作用がある可能性があります。 このスクリプトを実行する前に、update.phpを実行し、データの破損がないことを確認してください。

sql.php は、SQL クエリを実行できるようにするメンテナンス用ファイルです。 If you give an SQL file as the first argument, it will replace MediaWiki specific code comments like /*_*/ for the configured database prefix (among others). If you don't give it a file, then you can query the database in an interactive fashion, similar to the MySQL command line tool.

This script is often used if you want to upgrade MediaWiki, but have a large, master/replica-database setup and don't want any downtime. Instead of using update.php, you might use sql.php to apply database individual patches from maintenance/archives directory on each sql server separately, taking the individual server out of rotation while the schema change runs. Generally you should only do this if you have to - most users should use the update.php script instead.

オプション/引数

コマンドラインから利用できるスクリプト:

オプション 説明 必須かどうか
--query 対話モードを使用せず、一つのクエリのみを実行する 省略可能
--json 結果をPHPオブジェクトでなくJSONとして出力する 省略可能
--status Return successful exit status only if the query succeeded (selected or altered rows), otherwise 1 for errors, 2 for no rows 省略可能
--cluster Allows a cluster name to be provided for the command. 省略可能
--wikidb Allows for a different database to be used in the command by ID if not the current database. 省略可能
--replicadb Replica DB server to use instead of the primary DB (can be "any") 省略可能

使用法

php maintenance/sql.php [ --query| --json| --status| --cluster| --wikidb| --replicadb ]

対話モード

Terminal

インラインクエリ

Terminal

パッチの適用

Terminal

関連項目