简体   繁体   中英

Run system commands when logged into MySQL

This is NOT about MySQL's "data directory".

When I log into MySQL on my machine (Windows 10 OS) I know that MySQL still has a "current working directory": importing a .sql file works, giving only the filename, if the file is located in the same directory as the one where I went

> mysql -u ....

So I wondered whether it was possible to get the CWD when actually logged into MySQL. Then I wondered whether it might be possible to change it, ie to navigate somewhere else. Then I wondered about running system (ie command prompt) commands generally, while still logged in to MySQL.

Here we see a claim that you can indeed do all these things... by going something like:

\! ls -l

On my machine this doesn't work... probably because it's not a Linux OS. I get unknown command '\\!' ...

Is there any way to do this in Windows?

You're right. The Windows version of the mysql command line client lacks the shell escape \\! command.

It is an open source project :-). You or I could give them a pull request with a fix. But then we'd have to decide whether we wanted cmd or powershell in the escaped process.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM