Bug #104112 Provide a global place to provide system-wide mysql shell configuration
Submitted: 25 Jun 2021 11:24 Modified: 25 Jun 2021 11:55
Reporter: Simon Mudd (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:Shell General / Core Client Severity:S4 (Feature request)
Version:8.0 OS:Any
Assigned to: CPU Architecture:Any
Tags: configuration, global settings, mysqlshell

[25 Jun 2021 11:24] Simon Mudd
Description:
The MySQL shell appears to have no global settings for the required configuration values which we might want to use. You can provide settings which you can set locally in your home directory or provide them on the command line but often a system administrator might wish to configure default settings for all users of the  shell. Right now that is not possible.

A recent feature provided syslogging which can be convenient for monitoring usage etc of the shell or errors but that requires providing the --syslog option which can easily be forgotten.

This sort of facility is available for the mysql command line which uses /etc/my.cnf (or similar) globally and then overrides some settings with ~/.my.cnf.

How to repeat:
Look for documentation on how to configure default settings for users and find that only local settings are possible.

https://dev.mysql.com/doc/mysql-shell/8.0/en/mysql-shell-configuring-options.html
(Configuration File) section.

Suggested fix:
* Decide on a global location / configuration file to check for configuration.
* If present first read the settings from that file.
* Then check for the existing local configuration file and use any settings from that.

Personally I would prefer to use the existing /etc/my.cnf with a section [mysqlshell] but I'm not 100% sure if the existing configuration matches.

The exact location or file format is not important, just ensure it is documented, readable first by all users.
[25 Jun 2021 11:27] Simon Mudd
Related to: bug#99927
[25 Jun 2021 11:55] MySQL Verification Team
Hello Simon,

Thank you for the feature request!

regards,
Umesh
[25 Jun 2021 13:51] Daniël van Eeden
Putting things in /etc/mysql/mysqlsh/mysqlshrc.js as described on https://dev.mysql.com/doc/mysql-shell/8.0/en/mysql-shell-creating-startup-scripts.html might be a good workaround.

example:
shell.options["pager"] = "less"

Now in mysqlsh:

 JS  shell.options
{
    "autocomplete.nameCache": true, 
    "batchContinueOnError": false, 
    "credentialStore.excludeFilters": [], 
    "credentialStore.helper": "default", 
    "credentialStore.savePasswords": "prompt", 
    "dba.gtidWaitTimeout": 60, 
    "dba.logSql": 0, 
    "dba.restartWaitTimeout": 60, 
    "defaultCompress": false, 
    "defaultMode": "sql", 
    "devapi.dbObjectHandles": true, 
    "history.autoSave": false, 
    "history.maxSize": 1000, 
    "history.sql.ignorePattern": "*IDENTIFIED*:*PASSWORD*", 
    "history.sql.syslog": false, 
    "interactive": true, 
    "logLevel": 5, 
    "oci.configFile": "/home/dvaneeden/.oci/config", 
    "oci.profile": "DEFAULT", 
    "outputFormat": "table", 
    "pager": "less",               <---------------------------------
    "passwordsFromStdin": false, 
    "resultFormat": "table", 
    "sandboxDir": "/home/dvaneeden/mysql-sandboxes", 
    "showColumnTypeInfo": false, 
    "showWarnings": true, 
    "useWizards": true, 
    "verbose": 0
}