question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

New parser: my_print_defaults

See original GitHub issue

Both MariaDB and MySQL provide my_print_defaults for displaying MariaDB / MySQL configuration.

They are not exactly the same, for example the MySQL version has a -s option and the MariaDB version doesn’t, but I don’t think the differences would matter for a jc parser.

Usage examples:

my_print_defaults -c /home/example/.my.cnf client
--user=example
--password=XXX
--socket=/run/mysqld/mysqld.sock

my_print_defaults -c /etc/mysql/mariadb.conf.d/50-server.cnf mysqld
--user=mysql
--pid-file=/var/run/mysqld/mysqld.pid
--socket=/var/run/mysqld/mysqld.sock
--port=3306
--basedir=/usr
--datadir=/var/lib/mysql
--tmpdir=/tmp
--lc-messages-dir=/usr/share/mysql
--skip-external-locking
--bind-address=127.0.0.1
--key_buffer_size=16M
--max_allowed_packet=64M
--thread_stack=192K
--thread_cache_size=8
--myisam_recover_options=BACKUP
--max_connections=80
--max_user_connections=0
--table_cache=64
--thread_concurrency=10
--open_files_limit=122880
--table_open_cache=6000
--tmp_table_size=32M
--join_buffer_size=8M
--max_heap_table_size=32M
--query_cache_type=0
--query_cache_limit=0
--query_cache_size=0
--log_error=/var/log/mysql/error.log
--expire_logs_days=10
--max_binlog_size=100M
--innodb_buffer_pool_size=1G
--innodb_log_file_size=256M
--character-set-server=utf8mb4
--collation-server=utf8mb4_general_ci

I think that producing JSON would be a matter of, for each line of results, removing the -- at the start, then splitting the string at the = sign.

Note that the use of - or _ in configuration options is interchangable, perhaps it would make sense to change all dashes in variable names into underscores for consistency?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
kellyjonbrazilcommented, Jun 8, 2022

Yeah I can fix that. I already do it for double quotes but didn’t think to do it for single quotes. You can use the -r or raw option to get the quotes back, if needed.

1reaction
chriscroomecommented, Jun 6, 2022

The mysqltuner Perl script has a --json output option available after libjson-perl has been installed and this together with my_print_defaults and the jc --kv parser results in so much JSON data that I think this issue can be closed! Thanks for considering it @kellyjonbrazil

Note however that some of the variables names have spaces in them so you might need to use something else to filter the results before they can easily be accessed by something like Ansible, for example:

mysqltuner --json | jq '."Adjust variables"'
[
  "query_cache_size (=0)",
  "query_cache_type (=0)",
  "tmp_table_size (> 16M)",
  "max_heap_table_size (> 16M)",
  "performance_schema = ON enable PFS",
  "innodb_buffer_pool_size (>= 960.2M) if possible.",
  "innodb_log_file_size should be (=64M) if possible, so InnoDB total log files size equals to 25% of buffer pool size."
]
Read more comments on GitHub >

github_iconTop Results From Across the Web

Eclipse SUMO - Simulation of Urban MObility ...
const bool, myPrintDefaults ... [in], newID, The new id of this object ... Referenced by Distribution_Parameterized::parse(), ...
Read more >
UNISYS A Series System Softwa re - Bitsavers.org
This guide provides the reader with information required to make decisions about ... The LOAD command loads a previously generated screen as the...
Read more >
System Software Utilities Operations Reference Manual - Unisys
The LOAD command loads a previously generated screen as the new screen. ... commands at the ODT, you can either enter the DA...
Read more >
QuickDraw GX Printing Extensions and Drivers - Vintage Apple
Reading, Massachusetts Menlo Park, California New York ... The parse range results enumeration provides the constants that are used as the return.
Read more >
Артеменко Ю.Н. - MySQL Руководство администратора | PDF
"my_raid_createf:: undefined reference to "operator new(unsigned)' ... MySQL, mysqladmin parse error near 'SET password' ( 'SET password'). MySQL.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found