Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bash: mysql: command not found

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!

like image 960
Archie1008 Avatar asked Jun 13 '17 20:06

Archie1008


People also ask

How do I run MySQL in Git bash?

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.


2 Answers

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.

like image 76
Syed Ekram Uddin Avatar answered Sep 17 '22 20:09

Syed Ekram Uddin


If everything has been followed by the book mysql wont work (as I have tried) but mysqlsh instead will do the work.

like image 36
Bjorn Liza Avatar answered Sep 17 '22 20:09

Bjorn Liza