I will show you the best way to connect to MySQL from the command line in Windows. The best practice would be to mysql -u root -p. Then MySQL will prompt for a password after you hit enter.

 mysql -u root -p







MySQL is not recognized as an internal or external command

  • MySQL location in XAMPP:  C:\xampp\mysql\bin
  • MySQL location in WAMP:  C:\wamp64\bin\mysql\mysql8.3.0\bin



In Windows, set the system variables

  • variable name: MYSQL_HOME
  • variable value:C:\wamp64\bin\mysql\mysql8.3.0\bin




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: