mysql system command

24,345

Solution 1

System is going to spawn a child process to run a shell command.....

Current working directory is a process level property....so you can't change it in the parent from a child process. That's why it doesn't work.

I briefly scanned the MySQL docs at http://dev.mysql.com/doc/refman/5.5/en/mysql-commands.html but didn't see a direct CD command that changes the working directory. I think an adventurous person could write one....

Solution 2

If you want to change your current working directory for a script, then use the && between the CD and script so it will change directory and then if that's successful it will execute the second command.

mysql> SYSTEM cd /home && ls
Share:
24,345
Alex
Author by

Alex

Updated on July 13, 2020

Comments

  • Alex
    Alex almost 4 years

    I am in MySQL and would like to change the current working directory. I tried to execute:

    mysql> system cd './my_dir'
    

    However, this does not seem to work. Has anyone run into a similar problem?