Manual:Sql.php/ja

MediaWiki バージョン:
1.10
Category:MediaWiki code/ja#Sql.php
警告 警告: 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 sql/mysql 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として出力する省略可能
--statusReturn successful exit status only if the query succeeded (selected or altered rows), otherwise 1 for errors, 2 for no rows省略可能
--clusterAllows a cluster name to be provided for the command.省略可能
--wikidbAllows for a different database to be used in the command by ID if not the current database.省略可能
--replicadbReplica DB server to use instead of the primary DB (can be "any")省略可能

使用法

php maintenance/run.php sql [ --query| --json| --status| --cluster| --wikidb| --replicadb ]
MediaWiki バージョン 1.39.12 以前では、メンテナンス スクリプトを php maintenance/run.php scriptName ではなく php maintenance/scriptName.php を使用して実行する必要があります。

対話モード

Terminal

インラインクエリ

Terminal

パッチの適用

Terminal

関連項目

Category:Maintenance scripts/ja Category:Database maintenance scripts/ja
Category:Database maintenance scripts/ja Category:Maintenance scripts/ja Category:MediaWiki code/ja