Questions tagged [mysqldump]

MySQL's Standard Dump/Backup Utility

mysqldump is the client backup program used to dump a database or a collection of databases for backup or transfer to another SQL server.

The output of a mysqldump typically contains SQL statements to create the database schema, only the data, stored procedures, triggers, subsets of data using where clauses, or combinations of them all. Additionally, mysqldump can also be used to generate files in CSV, other delimited text, or XML format.

By default, mysqldump will dump all databases alphabetically, and table alphabetically within each database. If you use your imagination, you can find more creative ways to mysqldump data faster using shell scripting in conjunction with background processes. Also by default, mysqldump uses --opt, which specifies

  • --add-drop-table
  • --add-locks
  • --create-options
  • --disable-keys
  • --extended-insert
  • --lock-tables
  • --quick
  • --set-charset

There are many options that control mysqldump's behavior when dumping MyISAM and InnoDB data, plus accommodations for making the mysqldump's output perform such things as:

  • Binary Log Rotation on the Master prior to dumping
  • Preparing Replication Slaves to change replication coordinates (master Log file,master log position) during reload
  • Adding FLUSH PRIVILEGES; to update user credentials on the server being loaded
  • Make all InnoDB tables dump at the same point-in-time (--single-transaction)

Another feature of mysqldump is the dumping of individual tables in conjunction with a WHERE clause (--where). This allows for dumping portions of a table. If the --where clause involves "EXISTS IN other tables" conditions via JOINs or sub-SELECTs, you must use --lock-all-tables (normally the default, with the exception of dumping an individual table).

742 questions
36
votes
3 answers

mysqldump: Got error: 1044: Access denied for user 'username'@'localhost' to database 'databasename' when using LOCK TABLES

mysqldump: Got error: 1044: Access denied for user 'username'@'localhost' to database 'databasename' when using LOCK TABLES I am able to loging properly and able to take full backup from SQLyog Tool but when i am trying to take backup from MySQL…
Md Haidar Ali Khan
  • 6,447
  • 9
  • 38
  • 60
6
votes
1 answer

mysqldump with LIMIT and --order-by-primary

I want to use mysqldump to retrieve X first rows from a database (where "first" are ordered by primary key). I'm trying to use mysqldump the following way: mysqldump [connection-info] -where"1=1 LIMIT 40" --order-by-primary database table >>…
lcjury
  • 257
  • 4
  • 8
3
votes
1 answer

mysqldump: Got error: 1066: Not unique table/alias

What usually causes this mysqldump error? exec error: Error: Command failed: mysqldump: Got error: 1066: Not unique table/alias: 'TableFoo' when doing LOCK TABLES
gae123
  • 261
  • 1
  • 2
  • 6
3
votes
1 answer

Is there any risk associated with stopping mysqldump incomplete?

I started to backup 30GB table at wrong time and now I want to stop it because it is estimated to take 7.5hours. I used following command and options: mysqldump -u db -p user table --hex-blob | gzip> 25Nov-table.sql.gz My question is how to stop…
Rick James
  • 1,271
  • 3
  • 15
  • 19
2
votes
4 answers

Using mysqldump on RDS to export a large file in TSV format

I would like to export a single, large table (30GB) from an RDS MySQL server on a regular basis into a TSV file, so that we can load the file into Vertica. However, RDS doesn't provide a way to use mysqldump with the --tab=path option, so we need to…
braveheart
  • 21
  • 2
2
votes
1 answer

mysqldump confusion

I must be missing something. The line I keep seeing everywhere for a consistent backup is: mysqldump --single-transaction --all-databases > alldbs.sql Yet the MySQL docs indicate --opt is on by default. In that is --lock-tables. Also at MySQL docs…
2
votes
1 answer

Backup everything except one record

I want to backup my database except t1 table's one record (where option='siteurl'). I'm trying mysqldump's --where command. mysqldump -u root --skip-extended-insert --where "option='siteurl'" konsertvdb t1 > sql.sql This will work if I backup only…
Eray
  • 123
  • 5
2
votes
1 answer

Mysqldump with ansible for database backup

I am trying to backup remote database using ansible and mysqldump. I have installed ansible in my local server.Generated the ssh keys. I also sent the public key to the remote server. Everything is fine in ansible part but can't backup using ansible…
rackwadi
  • 65
  • 1
  • 2
  • 8
1
vote
0 answers

mysqldump issues with DreamHost

Background: I sought to rename a database on Dreamhost web hosting VPS account. I also wanted to rename a database user for the database to be created above. I followed the approached detailed at ServerFault I used mysqldump to create a backup of…
Sysuser
  • 11
  • 3
1
vote
0 answers

MySQL Why does mysqldump break/just stop? Improve my mysqldump command

I use the following command to backup my MySQL (with mysqldumpl) two times a day: /usr/local/mysql/bin/mysqldumpl --lock-tables=false --default-character-set=utf8 -h'host' -u'user' -p'pass' -f -v db266991x2616700 | gzip >…
Phantom
  • 111
  • 3
1
vote
1 answer

mysqldump error

I'm using mysql version 5.0.5 and trying to dump my data, in order to prepare for version upgrading, and get an error. I run: ./mysqldump -u root -p --add-drop-table --all-databases > /data/all_db_dump.mysql And get: mysqldump: Error 2013: Lost…
Omri
  • 353
  • 1
  • 5
  • 17
1
vote
2 answers

How can I validate if the MySQL dump was restored correctly?

I am taking a backup on a live system where inserts are going on. The backup size is around 50 GB. I have started the restore of the backup but for some reason I have not enabled the log, and also my session terminated. How can I verify that restore…
suraj
  • 11
  • 3
0
votes
1 answer

how do i print a record coming from joinig query as follows in mysql

tbl_A --------------- | a_id | a_name | |------|--------| | 1 | john | | 2 | paul | | 3 | joy | --------------- tbl_B --------------- | a_id | b_name | |------|--------| | 1 | x | | 1 | y | | 1 | z | …
0
votes
0 answers

mysqldump slow alter table issue

I notice mysqldump always put the command ALTER after INSERT. CREATE TABLE ...; INSERT table ....; ALTER TABLE ...; Is it possible to change the sequence to ALTER table first? CREATE TABLE ...; ALTER TABLE ...; INSERT table ....; When restoring…
neobie
  • 131
  • 2
  • 7
0
votes
1 answer

Incomplete MYSQL Dumps

I am using MySQL dump to back up my MySQL Databases and I'm having trouble with a couple dumps on one box. Server Specs Windows 2008 MySQL 5.1.48-community I've tried various parameters in the mysqldump command and not much seems to…
Bryan Smith
  • 137
  • 3
1
2