Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows OS(Win10) is not fully supported. #482

Closed
Luuk34 opened this issue Feb 17, 2020 · 2 comments
Closed

Windows OS(Win10) is not fully supported. #482

Luuk34 opened this issue Feb 17, 2020 · 2 comments

Comments

@Luuk34
Copy link

Luuk34 commented Feb 17, 2020

I created a patch which should help in solving "Windows OS(Win10) is not fully supported."
I am not good at programming in Perl, so please can someone test, and comment?

i know about 1 error around line 2380....
Use of uninitialized value $autoincrement in pattern match (m//) at mysqltunerLV.pl line 2380 (#1)

diff  D:/TEMP/mysqltuner/mysqltuner.pl D:/TEMP/mysqltuner/mysqltunerLV.pl
415c415
<     my $os = `uname`;
---
>     my $os = "$^O";   
479c479
<         elsif ( $os =~ /windows/i ) {
---
>         elsif ( $os =~ /mswin32/i ) {
662a663
> 	my $osext = "$^O" =~ /MSWin32/ ? ".exe" : "";
667c668,669
<         $mysqladmincmd = which( "mysqladmin", $ENV{'PATH'} );
---
>         $mysqladmincmd = which( "mysqladmin".$osext, $ENV{'PATH'} );
> 		debugprint("$mysqladmincmd");
678a681
>     if ( $mysqladmincmd =~ / / ) { $mysqladmincmd = chr(34).$mysqladmincmd.chr(34); }
683c686
<         $mysqlcmd = which( "mysql", $ENV{'PATH'} );
---
>         $mysqlcmd = which( "mysql".$osext, $ENV{'PATH'} );
694a698
>     if ( $mysqlcmd =~ / / ) { $mysqlcmd = chr(34).$mysqlcmd.chr(34); }
766c770
<         $mysqllogin = "-u $opt{user} -p'$opt{pass}'" . $remotestring;
---
>         $mysqllogin = "-u $opt{user} -p\"$opt{pass}\"" . $remotestring;  
931c935
<                 $mysqllogin .= " -p'$password'";
---
>                 $mysqllogin .= " -p\"$password\"";   
933a938
> 
934a940
> 
951a958
> 
964c971
<     my @result = `$mysqlcmd $mysqllogin -Bse "\\w$req" 2>>/dev/null`;
---
>     my @result = `$mysqlcmd $mysqllogin -Bse "\\w$req" 2>>nul`;
971c978
< 
---
> 		@result = "error";
989c996
<     my $result = `$mysqlcmd $mysqllogin -Bse "\\w$req" 2>>/dev/null`;
---
>     my $result = `$mysqlcmd $mysqllogin -Bse "\\w$req" 2>>nul`;
996c1003
< 
---
>         $result = "error";  
1639,1649c1646,1658
<     $result{'OS'}{'Type'} = `uname -o`;
<     infoprint "Operating System Type : " . infocmd_one "uname -o";
<     $result{'OS'}{'Kernel'} = `uname -r`;
<     infoprint "Kernel Release        : " . infocmd_one "uname -r";
<     $result{'OS'}{'Hostname'}         = `hostname`;
<     $result{'Network'}{'Internal Ip'} = `hostname -I`;
<     infoprint "Hostname              : " . infocmd_one "hostname";
<     infoprint "Network Cards         : ";
<     infocmd_tab "ifconfig| grep -A1 mtu";
<     infoprint "Internal IP           : " . infocmd_one "hostname -I";
<     $result{'Network'}{'Internal Ip'} = `ifconfig| grep -A1 mtu`;
---
> 	if ("$^O" !~ /MSWin32/ ) {
>      $result{'OS'}{'Type'} = `uname -o`;                                     
>      infoprint "Operating System Type : " . infocmd_one "uname -o";
>      $result{'OS'}{'Kernel'} = `uname -r`;
>      infoprint "Kernel Release        : " . infocmd_one "uname -r";
>      $result{'OS'}{'Hostname'}         = `hostname`;
>      $result{'Network'}{'Internal Ip'} = `hostname -I`;
>      infoprint "Hostname              : " . infocmd_one "hostname";
>      infoprint "Network Cards         : ";
>      infocmd_tab "ifconfig| grep -A1 mtu";
>      infoprint "Internal IP           : " . infocmd_one "hostname -I";
>      $result{'Network'}{'Internal Ip'} = `ifconfig| grep -A1 mtu`;
> 	}
1686c1695
<     my $os = `uname`;
---
>     my $os = "$^O";
2075c2084
<     if ( `uname` =~ /SunOS/ && `isainfo -b` =~ /64/ ) {
---
>     if ( "$^O" =~ /SunOS/ && `isainfo -b` =~ /64/ ) {
2079c2088
<     elsif ( `uname` !~ /SunOS/ && `uname -m` =~ /(64|s390x)/ ) {
---
>     elsif ( "$^O" !~ /SunOS/ && "$^O" !~ /MSWin32/ && `uname -m` =~ /(64|s390x)/ ) {
2083c2092
<     elsif ( `uname` =~ /AIX/ && `bootinfo -K` =~ /64/ ) {
---
>     elsif ( "$^O" =~ /AIX/ && `bootinfo -K` =~ /64/ ) {
2087c2096
<     elsif ( `uname` =~ /NetBSD|OpenBSD/ && `sysctl -b hw.machine` =~ /64/ ) {
---
>     elsif ( "$^O" =~ /NetBSD|OpenBSD/ && `sysctl -b hw.machine` =~ /64/ ) {
2091c2100
<     elsif ( `uname` =~ /FreeBSD/ && `sysctl -b hw.machine_arch` =~ /64/ ) {
---
>     elsif ( "$^O" =~ /FreeBSD/ && `sysctl -b hw.machine_arch` =~ /64/ ) {
2095c2104
<     elsif ( `uname` =~ /Darwin/ && `uname -m` =~ /Power Macintosh/ ) {
---
>     elsif ( "$^O" =~ /Darwin/ && `uname -m` =~ /Power Macintosh/ ) {
2101c2110
<     elsif ( `uname` =~ /Darwin/ && `uname -m` =~ /x86_64/ ) {
---
>     elsif ( "$^O" =~ /Darwin/ && `uname -m` =~ /x86_64/ ) {
2106a2116,2119
> 	elsif ("$^O" =~ /MSWin32/ && `wmic OS get OSArchitecture` =~ /64-bit/ ) { 
> 	    $arch = 64;
>         goodprint "Operating on 64-bit architecture";
> 	}
6340c6353
<     my @path_array  = split /:/, $ENV{'PATH'};
---
> 	my @path_array  = ("$^O" =~ /MSWin32/ ) ? split /;/, $ENV{'PATH'} : split /:/, $ENV{'PATH'};
6365a6379
> 

@KLBonn
Copy link

KLBonn commented Jul 6, 2020

I tried your patch on Windows Server 2016 with Strawberry Perl.

Applying your patch, I found error lines

...
[!!] failed to execute: SHOW TABLE STATUS FROM `mysql`
[!!] FAIL Execute SQL / return code: 256
[!!] failed to execute: SHOW TABLE STATUS FROM `performance_schema`
[!!] FAIL Execute SQL / return code: 256
[!!] failed to execute: SHOW TABLE STATUS FROM `sys`
[!!] FAIL Execute SQL / return code: 256

leading to

Use of uninitialized value $autoincrement in pattern match (m//) at
mysqltuner_windows.pl line 2380 (#1)

It seems this is due to the backslashes in the SQL command (line 2370 resp.

select_array "SHOW TABLE STATUS FROM \\\`$db\\\`"
)

Actually I could successfully execute the script with all escaping (backslashes) and backticks removed.

But I guess, in case of non-alphabetical schema names you still need the backticks?
Anyway, including the backticks without any escaping (backslashes) worked for me, too.

So, in my local file, the line above now looks like

              select_array "SHOW TABLE STATUS FROM `$db`"

...and the whole script works like a charm for me 😄

[Edit]
I would open a PR, but the patch from @Luuk34 above would break things for Linux-based environments.
So for true multiplatform support, I suppose some more refactoring should account for both ways.

@jmrenouard jmrenouard self-assigned this Feb 7, 2022
@jmrenouard
Copy link
Collaborator

Hi,

Windows is supported across WSL2
https://docs.microsoft.com/en-us/windows/wsl/

I close this issue
Jean-Marie

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants