You probably stumbled upon one of these two errors:
bash: mysql: command not found
error when you tried to run a MySQL command from the bash terminal'mysql' is not recognized as an internal or external command, operable program or batch file
error when you tried to run a MySQL command from the Command Prompt
Youâve come to the right place because in this post Iâm going to walk you through simple steps you can take to fix the MySQL command not found error on a Windows machine.
The source of the errors
The error occurs because Windows canât find the MySQL program, even though itâs probably already installed on your system.
To fix this, we need to add the MySQL executable to the PATH
environment variables.
Letâs do that.
Fix the errors
Open up the search bar and search for âenvâ then open up Edit the system environment variables.
Then go to Environment Variables -> select Path -> click Edit -> then New and then add the path to the MySQL \bin
folder.
Youâd have to decide if you want to add MySQL only for the current user, which in my case is Carol.
Or you want MySQL to be globally available for any users using your machine.
If youâre using the MySQL Server, then most likely the path is C:\Program Files\MySQL\MySQL Server 8.0\bin
.
In my case, Iâm using XAMPP so the path is C:\xampp\mysql\bin
As soon as youâre done editing, click OK, OK then apply and then try and run any MySQL commands.
If youâre using Git Bash in VS Code as I do, youâll have to restart VS Code first because itâs currently unaware of the new system variable we just added.
If youâre using Command Prompt, it should be able to work without restarting it.
Thatâs it! đ
Happy coding đ
Let me know what you think about this article in the comments section below.
If you find this article helpful, please share it with others and subscribe to the blog to support me, and receive a bi-monthly-ish e-mail notification on my latest articles.