sql_handle->datab"/> sql_handle->datab">
Home > Backend Development > PHP Tutorial > php在linux下调用system的有关问题

php在linux下调用system的有关问题

WBOY
Release: 2016-06-13 10:14:34
Original
1088 people have browsed it

php在linux下调用system的问题
请教大家一个问题
$cmd = "\"".$basedir."bin\mysqldump.exe\" --default-character-set=latin1 -uroot -ptest ".$this->sql_handle->database." > ".$doc_root."\\test\\test.sql";
$stat = -1;
system($cmd,&$stat);
这段代码在windows里可以正确的导出数据库

没有用过linux,请教大家,在linux下应该怎么修改?

------解决方案--------------------
--default-character-set=latin1 -u root -p test 参数名与参数需用空格格开
".$doc_root."\\test\\test.sql" 路径分隔符是/
------解决方案--------------------
这个是个很简单的脚本 你自己参考吧

#!/bin/sh
# File: /home/mysql/backup.sh
# Database info
DB_NAME="test"
DB_USER="username"
DB_PASS="password"

# Others vars
BIN_DIR="/usr/local/mysql/bin"
BCK_DIR="/home/mysql/backup"
DATE=`date %F`

# TODO
$BIN_DIR/mysqldump –opt -u$DB_USER -p$DB_PASS $DB_NAME | gzip > $BCK_DIR/db_$DATE.gz

------解决方案--------------------
linux 用exec


exec("mysqldump -uroot -p database table > /www/..... /sql.sql ");
------解决方案--------------------
/usr/local/bin/mysqldump
没有 .exe
------解决方案--------------------
最好切换apache/nginx用户执行下那个mysqldump命令,确定不是权限问题。
------解决方案--------------------
/usr/local/bin/mysqldump -uusername -ppwd dbname > /usr/local/www/data/test/test.sql
确定有/usr/local/bin/mysqldump 这个文件,具体可用
var_dump( system("ls /usr/local/bin") );看看有没有'mysqldump'
修改/usr/local/www/data/test/权限到所有用户可写
一直都是直接在本机终端下做这些,用php没做过所以只能给你这点建议

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template