Jump to content
MediaWiki

Manual:mysql.php

From mediawiki.org
MediaWiki file: mysql.php
Location: maintenance/
Source code: master1.43.11.42.61.39.12
Classes: MysqlMaintenance

Details

[edit ]

The mysql.php maintenance script executes the MySQL client binary by connecting to the wiki's database. It takes credentials from LocalSettings.php and logs in to MySQL client.

Options

[edit ]
Option Description Required
--write Connect to the primary database Optional
--group Specify query group Optional
--host Connect to a specific MySQL server Optional
--list-hosts List the available database hosts Optional
--cluster Use an external cluster by name Optional
--wikidb The database wiki ID to use if not the current one Optional

Usage

[edit ]
phpmaintenance/run.phpmysql[--write|--group|--host|--list-hosts|--cluster|--wikidb]
In MediaWiki version 1.39.12 and earlier, you must invoke maintenance scripts using php maintenance/scriptName.php instead of php maintenance/run.php scriptName.

Log in to MySQL client

[edit ]
Terminal
$ php maintenance/run.php mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.26 Homebrew
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>

List database hosts

[edit ]
Terminal
$ php maintenance/run.php mysql --list-hosts
primary.serv.er
replica1.serv.er
replica2.serv.er

Log in to MySQL client with cluster

[edit ]

If you use a database cluster to run your wiki with $wgExternalServers, you can use the --cluster option to log in.

$wgExternalServers = [
	'demoCluster' => [
		[ 'host' => 'leader.example.org', 'user' => 'userM', 'password' =>'pwdM', 'dbname' => 'dbM', 'type' => "mysql", 'load' => 1 ],
		[ 'host' => 'follower1.example.org', 'user' => 'userS1', 'password' =>'pwdS1', 'dbname' => 'dbS1', 'type' => "mysql", 'load' => 1 ],
		[ 'host' => 'follower2.example.org', 'user' => 'userS2', 'password' =>'pwdS2', 'dbname' => 'dbS2', 'type' => "mysql", 'load' => 1 ]
 ]
];
Terminal
$ php maintenance/run.php mysql --cluster demoCluster
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 25
Server version: 8.0.26 Homebrew
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>

Common error

[edit ]
Error: invalid cluster

This error occurs when an invalid or non-existent cluster name is given to the script.

Error: this script only works with MySQL/MariaDB

This error occurs when you run the script on a wiki that uses sqlite.

See also

[edit ]

AltStyle によって変換されたページ (->オリジナル) /