How to go to MySQL prompt using cmd without setting environment variable or without navigating MySQL service folder in Windows

I want to run the bat file at the mysql prompt automatically on all computers without setting the environment variable path.

I use the Xampp server, but some of my friends use Wampp and MysqlServer. However, I want to run my SQL commands by running the .bat file. So first I want to go to the MySql> prompt.

I tried to execute the CMD command to find the service,

tasklist /svc >mysqld.exe 

but i cant go to mysql>

Help me if anyone has any solution. Thanks.

+6
source share
1 answer

This would do the trick:

 for /f "tokens=3 skip=3" %a in ('tasklist /svc /fi "imagename eq mysqld.exe"') do @cmd /c sc qc %a ^| findstr PATH 
+1
source

All Articles