3

When I am running mysql in the terminal

I can do something like \! python ~/run.py to run the the file.

However when I copy this to php and do mysql_query it doesnt work.

2
  • 1
    I'd say you should do everything you can possibly do to make MySQL not execute shell commands :) Commented Sep 5, 2010 at 21:11
  • That's right You shouldn't be trying to do that. If you want to run a shell command from php use system(), exec() or the back-ticks. Commented Sep 5, 2010 at 21:57

2 Answers 2

4

You cannot run any of the \ prefix mysql commands in PHP's mysql_query.

Only valid SQL commands can be used.

Sign up to request clarification or add additional context in comments.

Comments

2

You can't do that.

The \! commands in the MySQL Console are provided by the Console itself, not by the MySQL server proper. In other words, these commands are not sent to the MySQL server, but they are passed to the shell from which the console was launched (e.g. bash). This is a convenience shortcut, but won't work with normal SQL commands.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.