robembra Posted January 4, 2010 Author Share Posted January 4, 2010 $sql = mysql_query('SELECT @@basedir as dir'); $row = mysql_fetch_array($sql); echo $row['dir']; I found a small update to the query... but as for your question I don't know... This outputted: /usr/local/ At least I'm a step closer I just need "bin" on the end Would mysql always be installed */bin/mysql is that why its output is /usr/local/ or am I not getting the correct output??? Thanks again Yes mysql's startup is kinda hinkey stuff -- it's just scripts, but they do append a /bin onto the end of basedir. It's kind of silly that there isn't a system variable in mysql that shows you the path to the binary, but ... oh well. Of course it's not really clear why you need to know this. For example, there could easily be a php install that has no mysql binaries available, and only the client librariy, because the webserver is connecting to a mysql server on a different host. My main reasion is to use mysqldump as it needs the path on some hosts: e.g. /usr/local/bin/mysqldump -h $hostname -u $username --password=$password $dbname | gzip > $mysqldump Quote Link to comment https://forums.phpfreaks.com/topic/187001-get-mysql-path-as-a-var/page/2/#findComment-987979 Share on other sites More sharing options...
gizmola Posted January 4, 2010 Share Posted January 4, 2010 Hey one last thing about the prior discussion of whereis... if you run it with the -b switch it will only look for binaries. You can also capture the output directly into a string using the backtick operator. $out = `whereis -b mysql`; echo $out. You still have to parse off the front mysql: and explode out the findings, in case it returns multiples. Quote Link to comment https://forums.phpfreaks.com/topic/187001-get-mysql-path-as-a-var/page/2/#findComment-987981 Share on other sites More sharing options...
gizmola Posted January 4, 2010 Share Posted January 4, 2010 So, based on that info, you'd be better off just searching for mysqldump directly using whereis -b mysqldump. If you don't find it, your backup script is probably not going to work. Quote Link to comment https://forums.phpfreaks.com/topic/187001-get-mysql-path-as-a-var/page/2/#findComment-987986 Share on other sites More sharing options...
robembra Posted January 4, 2010 Author Share Posted January 4, 2010 Hey one last thing about the prior discussion of whereis... if you run it with the -b switch it will only look for binaries. You can also capture the output directly into a string using the backtick operator. $out = `whereis -b mysql`; echo $out. You still have to parse off the front mysql: and explode out the findings, in case it returns multiples. That outputs... mysql: No path tho Quote Link to comment https://forums.phpfreaks.com/topic/187001-get-mysql-path-as-a-var/page/2/#findComment-987988 Share on other sites More sharing options...
gizmola Posted January 4, 2010 Share Posted January 4, 2010 I guess you can try the basedir + /bin/mysqldump. Very strange that whereis can't find the binary, but you could be testing in a chrooted/fastcgi environment. Quote Link to comment https://forums.phpfreaks.com/topic/187001-get-mysql-path-as-a-var/page/2/#findComment-987996 Share on other sites More sharing options...
robembra Posted January 4, 2010 Author Share Posted January 4, 2010 I guess you can try the basedir + /bin/mysqldump. Very strange that whereis can't find the binary, but you could be testing in a chrooted/fastcgi environment. I am in a FastCGI environment is this why its blank???? Quote Link to comment https://forums.phpfreaks.com/topic/187001-get-mysql-path-as-a-var/page/2/#findComment-987997 Share on other sites More sharing options...
gizmola Posted January 4, 2010 Share Posted January 4, 2010 Yes probably. Fastcgi is often used in shared hosting environments, so that they can utilize suexec support in apache. This basically allows them to run apache vhosts as your hosting user, rather than having everyone share the global apache user needed with mod_php. Since your user is probably quite limited as to programs you can see if you were in a shell, php is likewise limited as to what files it can see, exec, etc. Quote Link to comment https://forums.phpfreaks.com/topic/187001-get-mysql-path-as-a-var/page/2/#findComment-988007 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.