130

I had set the MySQL path, but still getting the same error. Please let me know whether I followed the correct one or not.

MySQL location is: C:\Program Files\MySQL\MySQL Server 5.0\bin

In Windows, system variables I had set the path as:

  • variable name: MYSQL_HOME
  • variable value: C:\Program Files\MySQL\MySQL Server 5.0\bin

For PATH setting:

  • variable name: PATH
  • variable value: .;%JAVA_HOME%\bin;%MYSQL_HOME%\bin...

If it is not the correct one, please let me know the correct path and its settings.

Community
  • 1
  • 1
hari
  • 1,341
  • 2
  • 14
  • 16

16 Answers16

124

Simply type in command prompt :

set path=%PATH%;D:\xampp\mysql\bin;

Here my path started from D so I used D: , you can use C: or E:

enter image description here

Pratik Joshi
  • 11,485
  • 7
  • 41
  • 73
92

MYSQL_HOME variable value=> C:\Program Files\MySQL\MySQL Server 5.0\bin

%MYSQL_HOME%\bin

See the problem? This resolves to a path of C:\Program Files\MySQL\MySQL Server 5.0\bin\bin

Shahzad Barkati
  • 2,532
  • 6
  • 25
  • 33
David Fells
  • 6,678
  • 1
  • 22
  • 34
  • @ David Fells...Thanks alot for ur prompt reply...i have remmoved bin from variable value...when i type mysql -version...it showing error like:C:\>mysql -version ERROR 1045 (28000): Access denied for user 'ODBC'@'localhost' (using password: N O)....so where i went wrong...?? am novice in mysql...please dont mine ..if i ask simple questions.. – hari May 07 '11 at 09:24
  • 2
    If the above solution doesn't work, add `C:\Program Files\MySQL\MySQL Server 5.6\bin %MYSQL_HOME%\bin` to `Path` instead – Minh Triet Oct 16 '13 at 03:45
  • It's 2020 and FWIW, I had to use `C:\Program Files\MySQL\MySQL Server 5.7\bin\`` and `%MYSQL_HOME%\bin\`` to get it to work (Note the trailing '\'). I tried following the solution outlined above without the \ and with a ; , but the only thing that worked was with the \ – globalSchmidt Sep 03 '20 at 15:20
28

MYSQL_HOME:

C:\Program Files\MySQL\MySQL Server 5.0

Path:

%MYSQL_HOME%\bin;
Emmanuel Osimosu
  • 5,625
  • 2
  • 38
  • 39
15

MySQL location is: C:\Program Files\MySQL\MySQL Server 8.0\bin

In Windows, system variables I had set the path as:

variable name: MYSQL_HOME
variable value: C:\Program Files\MySQL\MySQL Server 8.025\bin

For User variable for user:

  • Click Path ---> NEW ---> C:\Program Files\MySQL\MySQL Server 8.0.25\bin

  • Click OK

  • Now check with cmd (mysql -V)

    You may get a command like this

    mysql  Ver 8.0.25 for Win64 on x86_64 (MySQL Community Server - GPL)
    

You're DONE.

11

enter image description here
Here is what I DO on my PC, I install all software that I usually used in G: partition not C: if my operating system is fall (win 10), Do not need to reinstall them again and lose time, Then How windows work it update PATH automatic if you install any new program or piece of software,

SO

I must update PATH like these HERE! all the software I usually used 1- I created a folder called Program Files 2- I install all my programs data in this folder 3-and then going to PATH and add it Don't forget ;

%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;G:\HashiCorp\Vagrant\bin;G:\xampp\php;G:\xampp\mysql\bin;G:\Program Files (x86)\heroku\bin;G:\Program Files (x86)\Git\bin;G:\Program Files (x86)\composer;G:\Program Files (x86)\nodejs;G:\Program Files (x86)\Sublime Text 3;G:\Program Files (x86)\Microsoft VS Code\bin;G:\Program Files (x86)\cygwin64\bin

enter image description here

Ahmad
  • 1,618
  • 5
  • 24
  • 46
Abubakr Elghazawy
  • 977
  • 14
  • 21
4

I am using xampp. For me best option is to change environment variables. Environment variable changing window is shared by @Abu Bakr in this thread

I change the path value as C:\xampp\mysql\bin; and it is working nice

Rajib
  • 392
  • 4
  • 16
3

enter image description here You can fix in 3 steps

you have to change course by first > Copy file path

   *my path is E:\Program\xampp\mysql\bin*

next in CMD I write the followin

that

set path=%PATH%;set path=%PATH%;E:\Program\xampp\mysql\bin

Don't forget to change PATH

2

In my case, it turned out to be a simple case of spacing.

Turns out, i had a space inserted after the last ; and before ""C:\Program Files\MySQL\MySQL Server 5.7" For this very simple reason, no matter what i did, MySql was still not being recognized.

Once i eliminated the spaces before and after path, it worked perfectly.

In retrospect, seems like a very obvious answer, but nobody's mentioned it anywhere.

Also, i'm new to this whole windows thing, so please excuse me if it sounds very simple.

Sahasra
  • 29
  • 1
2

You only have to set path in the system variables and you are done with the job. Here I will show you step by step:

Step1: Go the start taskbar and write environment and click on the edit system environment option:

enter image description here

Step2: After clicking a dialog box namely System Properties Will occur like this:

enter image description here

Step3: Click on environment variables and then inside system variables in which there is written path, double click on path a new dialog box namely edit environment variables will be pop up as shown:

enter image description here

Then add the address of the MySql bin in windows C the path by clicking new path option, in my laptop MySql was here so added this path C:\Program Files\MySQL\MySQL Server 8.0\bin, thats it click ok and run on command prompt mysql --version command and it will show the actual version of mysql installed at your pc

Ethan
  • 876
  • 8
  • 18
  • 34
Aditi Negi
  • 21
  • 1
1

If you use wamp server add C:\wamp64\bin\mysql\mysql5.7.31\bin to environment variables PATH

Swaleh Matongwa
  • 698
  • 9
  • 16
0

To make it easier to invoke MySQL programs in CMD, you can add the path name of the MySQL bin directory to your Windows system PATH environment variable:

follow the below link.

https://dev.mysql.com/doc/mysql-windows-excerpt/5.7/en/mysql-installation-windows-path.html

sanuja
  • 1
  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/31266600) – geertjanvdk Mar 15 '22 at 06:12
0

In my case changing the directory to

cd "C:\Program Files\MySQL\MySQL Server 8.0\bin"

.\mysql.exe -u root -p

I have noticed no changes but when I wrote mysql.exe

It ran perfectly

JayRizzo
  • 3,234
  • 3
  • 33
  • 49
0

If the error isn't solved after setting the system variables and path, check the path specified in User Variables. If the path is not set in user variables, add it. This worked for me.

  • 1
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jul 09 '22 at 06:18
0

This worked for me(Windows):

  1. Firstly in cmd type: where{space}MySQL{enter}--->It gives something like this: C:\Program Files\MySQL\MySQL Server 8.0\bin\mysql.exe

  2. Add path=C:\Program Files\MySQL\MySQL Server 8.0\bin to System variable. How to set path to system variable ?

  3. Close and restart your Command prompt. After that write from anywhere in cmd: mysql --version

It will give results: mysql Ver 8.0.28 for Win64 on x86_64 (MySQL Community Server - GPL)

0

I read all answers above and its really confusing and harder sometimes if it will not work.

So If you want a runtime solution

  • just go to your MySQL path wherever it has been stored.
  • And open terminal. there is a bin folder.
  • Go to that folder by cd bin
  • Done ! now you can use MySQL in the terminal using mysql -u root -p

in my case, I have a path like this

C:\wamp65\bin\mysql\mysql8.0.31\bin

TarangP
  • 2,711
  • 5
  • 20
  • 41
-1

In my case, I resolved it by adding this path C:\xampp\mysql\bin to system variables path and then restarted pash/cmd.

Note: Click me if you don't know how to set the path and system variables.

saee
  • 433
  • 1
  • 3
  • 15