php


Empty files generated from running `mysqldump` using PHP


I keep getting empty files generated from running
$command = 'mysqldump --opt -h localhost -u username -p \'password\' dbname > \'backup 2009-04-15 09-57-13.sql\'';
command($command);
Anyone know what might be causing this? My password has strange characters in it, but works fine with connecting to the db.
I've ran exec($command, $return) and outputted the $return array and it is finding the command. I've also ran it with mysqldump > file.sql and the file contains
Usage: mysqldump [OPTIONS] database [tables]
OR mysqldump [OPTIONS] --databases [OPTIONS] DB1 [DB2 DB3...]
OR mysqldump [OPTIONS] --all-databases [OPTIONS]
For more options, use mysqldump --help
So it would seem like the command is working.
Remove the space between -p and the password. If it didn't work, try to remove the quotes from the password
from MySQL documentation:
If you use the short option form (-p), you cannot have a space between the option and the password.
however, it is fine to have space with -h and -u options
I believe there are no spaces between -u and the actual username.
host: localhost user: peter password: pwd
would become:
-hlocalhost -upeter -ppwd
To put it in plain english, make sure to use the following options (all of them).
--user=USERNAME
--host=localhost
--password=****
The next non-option phrase should be your database name. If the command is followed by another non-option phrase, it will be treated as table names.
$command="mysqldump --xml --host=localhost --user=USERNAME --password=***** DBNAME > XMLTABLE.xml";
system($command);
This is how I have done it - output is with maximum gzip compression:
<?php exec("/usr/bin/mysqldump --opt --host=MYSQLHOSTNAME --user=MYSQLUSER --password=PASSWORD DATABASENAME | gzip -v -9 >DATABASENAME.". date("Y-m-d_H-i-s") . ".sql.gz");?>
$command = 'C:\xampp\mysql\bin\mysqldump --opt --user=root --host=localhost --password="password" my_db'.' > '.$backupdate.$sql_file_name; exec($command);
I faced the same issue and got it fixed by quoting the password. For example --password="yourpassword".
I had empty files too using mysqldump.
I run WampServer PHP7 under Windows 10.
system('mysqldump .... ') ;
Doen't work.
I had to add the full path (or add an Environment variable) :
system('C:\wamp64\bin\mysql\mysql5.7.9\bin\mysqldump.exe ...') ;

Related Links

How to index document pages that can be retrieved later into elasticsearch
Fail to upload image using Ajax on Laravel 5
How do I only select recipes that I have the ingredients for?
YouTube Analytics API: Finding total uploaded video count for a channel in PHP
Magento “The connection was reset” Error
Validate text that are missing terms
Symfony2, DoctrineParamConverter.php, Entity Object not found
How to add Product Image Programmatically in Magento 1.9.2
Delete all rows of CSV file except rows that contain a specific string
Get the 'name' of object(stdClass) from array
Facebook SDK PHP login “Bad Request”
mysql/php merging/combining row values
Saving data to Database from HTML Input
unexpected 'else' (T_ELSE) on an empty line [duplicate]
PHP Email Script won't send email [duplicate]
Buddypress ORDER BY custom sort option on members directory

Categories

HOME
macos-sierra
xcode
jms
hid
jersey-2.0
cryptography
facebook-android-sdk
hspi
azure-graph-api
mailmerge
grocery-crud
squid
hdl
candlestick-chart
raima
webviewclient
uri
math.js
splunk-query
docx4j
steam-web-api
nppexec
pdfminer
spinner
nsuserdefaults
reset
ejml
expandablelistview
permission-denied
sony-future-lab-n
openstack-glance
renderman
maven-jaxb2-plugin
aurelia-fetch-client
htmlspecialchars
glassfish-4.1
.when
gawk
oracle-fusion-apps
cocoa-bindings
libharu
nclam
jsf-2.3
system.net.mail
gcloud-node
yii2-model
apple-configurator
sharepoint-apps
jeditable
okta-api
cryptojs
blockquote
cache-manifest
angular-amd
alwayson
htmltidy
full-text-indexing
accessory
distributed-r
git-reset
senchatouch-2.4
assetic
spring-security-acl
apportable
insertion
notin
axacropdf
user-forums
audiotoolbox
clearinterval
telerik-ajax
zotonic
platform-independent
kolite
snackjs
asp.net-mvc-views
qcar-sdk
printqueue
active-record-query
tacit-programming
stretchblt
suggestbox
regioninfo
chronic

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App