Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

I am using Xampp server,but some of my friends using Wampp and MysqlServer. However I want to run my sql commands by running a .bat file.So I want to navigate to the MySql> prompt first.

I tried following CMD command to find the service,

tasklist /svc >mysqld.exe

but I can't navigate to mysql>

Help me if someone has any solution. Thanks.

like image 648
Preshan Pradeepa Avatar asked Dec 10 '15 04:12

Preshan Pradeepa


People also ask

How do I set environment variables in MySQL?

On the Windows desktop, right-click the My Computer icon, and select Properties. Next select the Advanced tab from the System Properties menu that appears, and click the Environment Variables button. Under System Variables, select Path, and then click the Edit button. The Edit System Variable dialogue should appear.


1 Answers

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
like image 51
Amnon Avatar answered Nov 15 '22 05:11

Amnon