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.88k stars 1.28k forks source link

Only pass `-P` for socket connection when port option is specified #731

Closed leonyu closed 1 year ago

leonyu commented 1 year ago

This fix implementation of be1f4b4 for GCP cloud-sql-proxy. cloud-sql-proxy creates multiple sockets on localhost pointing to multiple remote instances with default port.

$ curl -L http://mysqltuner.pl/ -o mysqltuner.pl
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100  254k  100  254k    0     0   524k      0 --:--:-- --:--:-- --:--:--  524k
$ MYSQL_PWD="[REDACTED]" ./mysqltuner.pl --socket=/cloudsql/[REDACTED] --user $USER --skippassword --forcemem 245760 --forceswap 0
 >>  MySQLTuner 2.2.12
     * Jean-Marie Renouard <jmrenouard@gmail.com>
     * Major Hayden <major@mhtx.net>
 >>  Bug reports, feature requests, and downloads at http://mysqltuner.pl/
 >>  Run with '--help' for additional options and output filtering

[--] Skipped version check for MySQLTuner script
[!!] Attempted to use login credentials, but they were invalid
exit 1
$ curl -LO https://raw.githubusercontent.com/leonyu/MySQLTuner-perl/master/mysqltuner.pl
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  254k  100  254k    0     0  2973k      0 --:--:-- --:--:-- --:--:-- 2999k
$ MYSQL_PWD="[REDACTED]" ./mysqltuner.pl --socket=/cloudsql/[REDACTED] --user $USER --skippassword --forcemem 245760 --forceswap 0
 >>  MySQLTuner 2.2.12
     * Jean-Marie Renouard <jmrenouard@gmail.com>
     * Major Hayden <major@mhtx.net>
 >>  Bug reports, feature requests, and downloads at http://mysqltuner.pl/
 >>  Run with '--help' for additional options and output filtering

[--] Skipped version check for MySQLTuner script
[OK] Logged in using credentials passed on the command line
[--] Assuming 245760 MB of physical memory
[!!] Assuming 0 MB of swap space (use --forceswap to specify)
[OK] Operating on 64-bit architecture

-------- Storage Engine Statistics -----------------------------------------------------------------
...
leonyu commented 1 year ago

@i5513 please take a look as well

jmrenouard commented 1 year ago

Thanks @leonyu