We have a new documentation site for cPanel & WHM! You can find our new documentation site at docs.cpanel.net.

We will continue to maintain our API documentation on this server.

Child pages
  • WHM API 1 Functions - set_local_mysql_root_password
Skip to end of metadata
Go to start of metadata

Description

This function resets the root user's password on the local MySQL® server.

Important:

In cPanel & WHM version 76 and later, when you disable the MySQL/MariaDB role and remote MySQL is not already configured, the system disables this function.

Examples 


 JSON API
https://hostname.example.com:2087/cpsess##########/json-api/set_local_mysql_root_password?api.version=1&password=12345luggage
 XML API
https://hostname.example.com:2087/cpsess##########/xml-api/set_local_mysql_root_password?api.version=1&password=12345luggage
 Command Line
whmapi1 set_local_mysql_root_password password=12345luggage


Notes:

  • Unless otherwise noted, you must URI-encode values.
  • For more information and additional output options, read our Guide to WHM API 1 documentation or run the whmapi1 --help command.
  • If you run CloudLinux™, you must use the full path of the whmapi1 command:

    /usr/local/cpanel/bin/whmapi1

 

 Output (JSON)
{
  "data": {
    "password_reset": 1
  },
  "metadata": {
    "version": 1,
    "reason": "OK",
    "result": 1,
    "command": "set_local_mysql_root_password"
  }
}
 Output (XML)
<result>
    <data>
        <password_reset>1</password_reset>
    </data>
    <metadata>
        <version>1</version>
        <reason>OK</reason>
        <result>1</result>
        <command>set_local_mysql_root_password</command>
    </metadata>
</result>


Note:

Use WHM's API Shell interface (WHM >> Home >> Development >> API Shell) to directly test WHM API calls.

Parameters

ParameterTypeDescriptionPossible valuesExample
passwordstring

Required

The new MySQL root user's password.

A valid string.12345luggage
update_configBoolean

Whether to update the configuration files.

Warning:

This parameter updates the /root/.my.cnf file with the new password, which could cause problems with the MySQL configuration on the server. If you are unsure, do not specify this parameter.

  • If you set this parameter to 0 when localhost is the active profile, it will stop communication with the remote MySQL server until you update the profile's password.
  • If you set this parameter to 1 when a remote host is the active profile, it will stop communication with the remote MySQL server until you update the profile's password.
  • 1 — Update.
  • 0 — Do not update.
1

Returns

Return

TypeDescriptionPossible valuesExample
password_resetBooleanWhether the system reset the password.
  • 1 — Reset.
  • 0Not reset.
1
configs_updatedBoolean

Whether the system updated the configuration settings.

Note:

This return only appears when the function includes the update_config parameter or when the localhost MySQL profile is active.

  • 1 — Updated.
  • 0Not updated.
1
profile_updatedBoolean

Whether the system updated the profile.

Note:

This return only appears when the localhost MySQL profile is active.

  • 1 — Updated.
  • 0Not updated.
1