major / MySQLTuner-perl

MySQLTuner is a script written in Perl that will assist you with your MySQL configuration and make recommendations for increased performance and stability.
GNU General Public License v3.0
8.86k stars 1.28k forks source link

Using --defaults-file ignores the .my.cnf #605

Open dugwood opened 2 years ago

dugwood commented 2 years ago

I was trying to use --defaults-file (same server, multiple MySQL instances for staging purposes), but adding --defaults-file prevent the --pass or .my.cnf reading.

According to MySQL documentation, that makes sense as defaults-file is the only file read: https://dev.mysql.com/doc/refman/8.0/en/option-file-options.html

But it would be great to implement either --defaults-extra-file, allow --pass to work, or allow using another file to read credentials (.mylogin.cnf is read by MySQL as a default).

Can you point me to the solution you'd rather implement, I could create a PR based on that choice?

Thanks!

jmrenouard commented 2 years ago

Hi,

Implementation could be adding defaults-extra-file in parameter list

Last commit 2.0.7 is a try for this feature

jmrenouard commented 2 years ago

Can you tell us about this --defaults-extra-file new option ?

dugwood commented 2 years ago

Thanks Jean-Marie,

The defaults-file erase the default configuration (say my.cnf) whereas defaults-extra-file will add / replace previous options set by my.cnf.

The idea is to load a master file (which may not be the my.cnf), then provide a user credentials (which may not be the root user).

My issue is that I've multiple MySQL instances on the same server (for development purposes), so I can't test anything else than the default server. Or I must set the credentials within the my.cnf, which I don't think is a good idea.

Perhaps using [mysqladmin] section is another good idea, but not being able to provide a specific user credentials is the may issue here (as --pass is ignored if --defaults-file is used).

dugwood commented 2 years ago

Sorry, just saw your 2.0.7 release. There's an issue with it, as defaults-extra-file isn't set instead of defaults-file, but along with it.

So it should be set within the defaults-file test: https://github.com/major/MySQLTuner-perl/blob/master/mysqltuner.pl#L906 (or duplicated in it).