我正在尝试在运行xampp 7.2.12-0的mac mojave 10.14.3上通过命令行运行以下脚本:
#!/bin/sh
PATH=/usr/local/bin:~/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Application/XAMPP/xamppfiles/bin
#----------------------------------------------------
# a simple mysql database backup script.
# version 2, updated March 26, 2011.
# copyright 2011 alvin alexander, http://devdaily.com
#----------------------------------------------------
# This work is licensed under a Creative Commons
# Attribution-ShareAlike 3.0 Unported License;
# see http://creativecommons.org/licenses/by-sa/3.0/
# for more information.
#----------------------------------------------------
# (1) set up all the mysqldump variables
database="mybackup"
backupdir="."
backupuser="root"
day=`date +%u`
mkdir -p $backupdir/$day
echo -n "Exporting $database..."
mysqldump --opt --user=$backupuser --all-databases > ./$day/$database.sql
echo -n "compressing..."
gzip ./$day/$database.sql
echo "done"
执行此脚本会产生以下命令行错误:
backup1.sh: line 22: mysqldump: No such file or directory
当我直接运行mysqldump命令时,它会正确执行。有人对我做错的事情有任何想法吗?
许可如下:
drwxrwxrwx+ 8 777 admin 256 Mar 16 08:44 .
drwxrwxrwx 4 777 admin 128 Mar 14 22:13 ..
-rw-r--r--@ 1 myLaptop admin 6148 Mar 15 22:17 .DS_Store
drwxr-xr-x 7 myLaptop admin 224 Mar 16 08:54 5
drwxr-xr-x 5 myLaptop admin 160 Mar 16 09:18 6
-rwxr-xr-x@ 1 myLaptop admin 1348 Mar 15 18:22 backup.sh
-rwxrwxrwx@ 1 myLaptop admin 878 Mar 16 09:18 backup1.sh
任何帮助,万分感谢!
答案 0 :(得分:0)
如果我删除
PATH=/usr/local/bin:~/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Application/XAMPP/xamppfiles/bin
然后该脚本起作用。
去吧?