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.
Best Answer
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
Here is the full version of error that you should be getting :
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 justmysql
after setting the current directory toC:\Program Files\mysql\MySQL Server 5.7\bin>
but this might lead you to another error which most probably will say :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.