I am using MAMP pro latest version Mac OS X 10.10
FROM cli I can run the following and it works:
exec("mysql --host=$db_host --user=$db_user --password=$db_password $db_name < $sql_file");
FROM apache/php it doesn't work and cannot find the executable.
It DOES work from apache/php if I do the following:
exec("/Applications/MAMP/Library/bin/mysql --host=$db_host --user=$db_user --password=$db_password $db_name < $sql_file");
What do I need to change to get this to work? It seems for some reason the environment variables aren't available when running from apache/php.
I solved this by finding out the the environment path was /usr/bin:/bin:/usr/sbin:/sbin
I find this via phpinfo. I then symlinked mysql and mysqldump into /usr/bin and that solved my problem. I was I knew how to add paths to php; but this was good enough for what I needed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With