I just installed MySQL server and a MySQL Workbench on my new desktop and trying to use MySQL commands in Git Bash
to create some databases locally in folder
C:\Users\OmNom\Desktop\code\burger\db
(database file located in this folder)
with
mysql -u root -p
but getting this message in return
bash: mysql: command not found
What am I doing wrong ? Do I have to install something else to make it work?
P.S. OS Windows 10 , Node.js installed , server runs fine (I'm able to create databases in workbench).
Please help!
P.P.S. If you need additional information let me know!
On the Start menu, select Run. In the Open box type cmd, and then select OK to open a Command Prompt window. At the command prompt, type sqlcmd. Press ENTER.
That's because your MySQL bin program (mysql command tool) not added to your windows PATH system variable.
Now this can happen for several reasons, one particular reason could be your installation executable not run as administrator. So to use it with your git bash you can do two things.
Approach 1
Go to the bin directory of your MySQL installation using git bash. For example
$ cd 'C:\Program Files\MySQL\MySQL Server 5.7\bin'
Then run
./mysql -u root -p
Approach 2
To make it easier to invoke MySQL programs, you can add the path name of the MySQL bin directory to your Windows system PATH environment variable. To do so follow the MySQL official documentation guideline from here
https://dev.mysql.com/doc/mysql-windows-excerpt/5.7/en/mysql-installation-windows-path.html
After adding the PATH variable you need to restart your git bash.
Now you'll able to run mysql command from anywhere using git bash.
If everything has been followed by the book mysql
wont work (as I have tried) but mysqlsh
instead will do the work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With