'mysql' Recognized by cmd but not PowerShell? I'm trying to run a very simple login script through powershell.

I have already added the default directory "C:\Program Files\MySQL\MySQL Server 5.7\bin" to the PATH variable. Now I was able to call mysql from command line prompt.

However when I tried to run the same script from PowerShell it showed that " The name 'mysql' is not recognized as the name of cmdlet, function, script file......"

My computer is running on Windows 10 64bit.
So as I am reading about powershell now a days and I find this interesting and wanted to know answer myself, on some googling here is what I found:

Considering that you are using  similar command as given below to fire the Mysql 


  PS C:\Program Files\mysql\MySQL Server 5.7\bin&gt; mysql


Here is the full version of error that you should be getting :


  mysql : The term 'mysql' is not recognized as the name of a cmdlet,
  function, script file, or operable program.  Check the spelling of the
  name, or if a path was included, verify that the     path is correct
  and try again. At line:1 char:1+ mysql
  + ~~~~~
          + CategoryInfo          : ObjectNotFound: (mysql:String) [],     CommandNotFoundException
      + FullyQualifiedErrorId : CommandNotFoundException
  
  Suggestion [3,General]: The command mysql was not found, but     does
  exist in the current location. Windows PowerShell does  not load
  commands from the current location by default. If you      trust this
  command, instead type: ".\mysql". See "get-he lp
  about_Command_Precedence" for more details.


If we see the Suggestion part it says Windows PowerShell does not load commands from the current location by default. If you trust this command, instead type: ".\mysql".

So try using .\mysql instead of just mysql after setting the current directory to C:\Program Files\mysql\MySQL Server 5.7\bin&gt; but this might lead you to another error which most probably will say :


ERROR 1045 (28000): Access denied for user 'ODBC'@'localhost' (usingpassword: NO)



which you can than resolve changing the syntax to mysql -u root -p

So it looks like kinda security thing that powersehll is imposing.

Source:1

Note: Try running $env:Path in powershell to see if the path is correctly set.