Manual:mysql.php

From Linux Web Expert

Revision as of 16:51, 9 March 2022 by imported>APaskulin (WMF) (Simplify language and table; use inclusive language)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Details

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

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

Usage

php maintenance/mysql.php [ --write| --group| --host| --list-hosts| --cluster| --wikidb ]

Log in to MySQL client

Terminal

List database hosts

Terminal

Log in to MySQL client with cluster

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

Common error

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