Problems related to php calling system in linux

Source: Internet
Author: User
Latency & quot; -- default-character-setlatin1-uroot-ptest & quot;. $ this-& gt; SQL _handle-& gt; datab php call system in linux
Ask you a question
$ Cmd = "\"". $ basedir. "bin \ mysqldump.exe \" -- default-character-set = latin1-uroot-ptest ". $ this-> SQL _handle-> database. "> ". $ doc_root. "\ test. SQL ";
$ Stat =-1;
System ($ cmd, & $ stat );
This code correctly exports the database in windows.

I have never used linux. how can I modify it in linux?

------ Solution --------------------
-- Default-character-set = latin1-u root-p test parameter name and parameter must be left blank
". $ Doc_root." \ test. SQL "path separator is/
------ Solution --------------------
This is a simple script for your reference.

#! /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_1_date.gz

------ Solution --------------------
Exec for linux


Exec ("mysqldump-uroot-p database table>/www/.../SQL. SQL ");
------ Solution --------------------
/Usr/local/bin/mysqldump
No. exe
------ Solution --------------------
You are advised to switch to the apache/nginx user and execute the mysqldump command to confirm that it is not a permission issue.
------ Solution --------------------
/Usr/local/bin/mysqldump-uusername-ppwd dbname>/usr/local/www/data/test. SQL
Check whether the file/usr/local/bin/mysqldump is available.
Var_dump (system ("ls/usr/local/bin'
Modify/usr/local/www/data/test/permission to allow all users to write
I have always done this directly on the local terminal. I have never used php, so I can only give you this advice.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.