I'm using MAMP PRO 5.5.1 on macOS Mojave 10.14.6.
I want to backup a MySQL database with the following command:
$backup = system("mysqldump -hmy_host -umy_user -pmy_password --databases my_databse > my_file.sql");
This isn't working, no file gets created. There is nothing in php_error.log
but apache_error.log
says the following:
sh: mysqldump: command not found
Since my script/command is working on another system (shared hosting, not MAMP), I'm sure, the script itself is working. There seems to be something wrong with MAMP.
Any idea what it is?
MAMP's binaries are not in your system's path so you need to call mysqldump explicitly like this:
/Applications/MAMP/Library/bin/mysqldump
You can create aliases to MAMP's binaries and add them to your .bashrc
(or whatever shell you're using) like this
alias mysql='/Applications/MAMP/Library/bin/mysql'
alias mysqldump='/Applications/MAMP/Library/bin/mysqldump'
alias mysqladmin='/Applications/MAMP/Library/bin/mysqladmin'
This way you can use the mysqldump
shorthand like you're used to. You can do the same for MAMP's multiple PHP Versions:
alias php71='/Applications/MAMP/bin/php/php7.1.32/bin/php -q -c /Library/Application\ Support/appsolute/MAMP\ PRO/conf/php7.1.32.ini'
alias php73='/Applications/MAMP/bin/php/php7.3.9/bin/php -q -c /Library/Application\ Support/appsolute/MAMP\ PRO/conf/php7.3.9.ini'
Now you have multiple php binaries with the corresponding ini files at hand on the command line as well. Just make sure to update the paths for use with the right php versions you're using, because MAMP Pro always updates the php packages to their latest versions with every update.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.