How can I use 'system pwd' command with MySql CONCAT() function? I tried
select concat('test', system pwd);
gives me
ERROR 1583 (42000): Incorrect parameters in the call to native function 'concat'
Is there any way? My database version 5.1
How can I use 'system pwd' command with MySql CONCAT() function? I tried
select concat('test', system pwd);
gives me
ERROR 1583 (42000): Incorrect parameters in the call to native function 'concat'
Is there any way? My database version 5.1
system
is not a recognized MySQL server command. This will only work on the MySQL command line interface "mysql". With a command like this:
mysql> system pwd
/tmp
you will get the client's current directory, nothing to do with the server. You cannot use that information on server side, for executing queries. If you want to concat the pwd
with something else, use a script at client side (bash, php). For example:
$ echo $(pwd)test
/tmptest
$ mysql -e "SELECT concat('$(pwd)', 'test')" # there is not reason to do this at all
+------------------------+
| concat('/tmp', 'test') |
+------------------------+
| /tmptest |
+------------------------+
While there is a custom non-standard UDF library to make MySQL server interact with the operating system, I do not see a valid use in your case.
If you want to know the directory where MySQL is installed, where the datafiles are, etc., you can execute:
mysql> SHOW GLOBAL VARIABLES like '%dir';
+---------------------------+--------------------------+
| Variable_name | Value |
+---------------------------+--------------------------+
| basedir | /usr/local/mysql |
| datadir | /usr/local/mysql/data/ |
...
You cannot call outside programs from within MySQL code. It is not allowed because of the serious security issues.