Reputation: 1611
I have a short PHP script which is supposed to perform a MySQL backup and email it to me. However, neither the data nor the structures are being written by mysqldump. The command to invoke mysqldump looks like this:
mysqldump --host=localhost --user=xxx --pass=xxx xxx_license > xxx2012-12-28.sql
(The xxx username and password are the same as from another script which works with php and the database so I know the credentials are correct).
The output is as follows:
-- MySQL dump 10.13 Distrib 5.5.28, for Linux (x86_64)
--
-- Host: localhost Database: xxx_license
-- ------------------------------------------------------
-- Server version 5.5.28-cll
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Current Database: `xxx_license`
--
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `xxx_license` /*!40100 DEFAULT CHARACTER SET latin1 */;
USE `xxx_license`;
The CREATE and USE statements are only present if I add --databases to the options.
And using --help to show the default options is:
mysqldump Ver 10.13 Distrib 5.5.28, for Linux (x86_64)
<snip>
Variables (--variable-name=value)
and boolean options {FALSE|TRUE} Value (after reading options)
--------------------------------- ----------------------------------------
all-databases FALSE
all-tablespaces FALSE
no-tablespaces FALSE
add-drop-database FALSE
add-drop-table TRUE
add-locks TRUE
allow-keywords FALSE
apply-slave-statements FALSE
character-sets-dir (No default value)
comments TRUE
compatible (No default value)
compact FALSE
complete-insert FALSE
compress FALSE
create-options TRUE
databases FALSE
debug-check FALSE
debug-info FALSE
default-character-set utf8
delayed-insert FALSE
delete-master-logs FALSE
disable-keys TRUE
dump-slave 0
events FALSE
extended-insert TRUE
fields-terminated-by (No default value)
fields-enclosed-by (No default value)
fields-optionally-enclosed-by (No default value)
fields-escaped-by (No default value)
flush-logs FALSE
flush-privileges FALSE
force FALSE
hex-blob FALSE
host (No default value)
include-master-host-port FALSE
insert-ignore FALSE
lines-terminated-by (No default value)
lock-all-tables FALSE
lock-tables TRUE
log-error (No default value)
master-data 0
max-allowed-packet 25165824
net-buffer-length 1046528
no-autocommit FALSE
no-create-db FALSE
no-create-info FALSE
no-data FALSE
order-by-primary FALSE
port 0
quick TRUE
quote-names TRUE
replace FALSE
routines FALSE
set-charset TRUE
single-transaction FALSE
dump-date TRUE
socket (No default value)
ssl FALSE
ssl-ca (No default value)
ssl-capath (No default value)
ssl-cert (No default value)
ssl-cipher (No default value)
ssl-key (No default value)
ssl-verify-server-cert FALSE
tab (No default value)
triggers TRUE
tz-utc TRUE
user (No default value)
verbose FALSE
where (No default value)
plugin-dir (No default value)
default-auth (No default value)
If something in those options is wrong, how do I change/override it? I can't find a config file and I don't have SSH access to the web server to perform any actions.
Thanks.
Upvotes: 5
Views: 17038
Reputation: 46
In my case I was uncontiously using wrong workbench version. Thus used mysqldump which did not export all rows, fortunately I checked couple of tables :).
Upvotes: 0
Reputation: 508
I had this same problem in MySql 5.7 trying to just capture the table structure. I had to explicitly put in --databases --tables on the command line in order to get this to work. For example with data and structure:
mysqldump --defaults-extra-file=$confFile --databases $db --tables $tables > ./backup_db.sql
Example with just the definition for one table:
mysqldump --defaults-extra-file=$confFile -d --databases $db --tables $table > ./table_cre.sql
Upvotes: 2
Reputation: 124
Can you run the dump from the command line? If you can't then start there. If you can, since is running through a PHP script, make sure your script has permission to write to the directory it is saving the dump to. Check the owner/group permissions and the permissions of the directory being saved to.
Upvotes: 0
Reputation: 188
I had the same issue, I resolved it by updating my "mysqldump.exe" to the latest version (the server and my backup server were out of sync in regards to the MySQL version)
Upvotes: 0
Reputation: 780974
Check the user's permissions, and make sure it has SELECT permissions to all the tables. And if it doesn't have permission to lock the tables, use --skip-lock-tables
.
Upvotes: 5
Reputation: 4053
Try the steps :
mysqldump –u[user-name] –p [database name] > [dump file]
press enter key
password
press enter key
mysqldump –uxxx –p xxx_license > xxx2012-12-28.sql
press enter key
now enter password
xxx
press enter key
Works for me.
Upvotes: 0