xelabs / go-mydumper

A multi-threaded MySQL backup and restore tool, faster than mysqldump
GNU General Public License v3.0
346 stars 100 forks source link

errror1050 Table xxx already exists #10

Closed long904 closed 6 years ago

long904 commented 6 years ago

ls isms_web_image.sql/

isms.isms_web_image.00001.sql isms.isms_web_image-schema.sql isms-schema-create.sql metadata

./bin/myloader -h 127.0.0.1 -u backup -p 'xxx' -P 3306 -d /data/isms_web_image.sql/

2018/03/21 17:24:08.172924 loader.go:76: [INFO] restoring.database[isms] 2018/03/21 17:24:08.173041 loader.go:87: [INFO] working.table[isms.isms_web_image] panic: Table 'isms_web_image' already exists (errno 1050) (sqlstate 42S01)

not full backup. It's need to drop isms_web_image first?but if a lot of table,how can i do?

BohuTANG commented 6 years ago

Hello,

By default, the loader tables should not be exists in the database, it's a full backup and cleanly load.

long904 commented 6 years ago

thank you. if i use single table bakcup. it's no cleanly?is there any other way?

BohuTANG commented 6 years ago

Hi,

There is a flag(-o) for this: https://github.com/xelabs/go-mydumper/blob/master/src/myloader/main.go#L36 -o Drop tables if they already exist

This flag does not document at README.

Try to run:

./bin/myloader -h 127.0.0.1 -u backup -p 'xxx' -P 3306 -d /data/isms_web_image.sql/ -o
long904 commented 6 years ago

thank you.

long904 commented 6 years ago

i try it.but don't work. ./bin/myloader -h 127.0.0.1 -u backup -p 'xxx' -P 3306 -d /data/isms_web_image.sql/ -o 2018/03/23 14:28:51.295775 loader.go:76: [INFO] restoring.database[isms] 2018/03/23 14:28:51.295887 loader.go:87: [INFO] working.table[isms.isms_web_image] panic: Table 'isms_web_image' already exists (errno 1050) (sqlstate 42S01)

BohuTANG commented 6 years ago

Hi long904,

I have add a log when dropping the table with the '-o' flag. Please re-pull the master branch and build again with the follow command: make build

commit id: https://github.com/xelabs/go-mydumper/commit/538d5b13e36751c20aff6d94338c07a15eafda13

long904 commented 6 years ago

./bin/myloader -h 127.0.0.1 -u backup -p 'xxx' -P 3306 -d /data/isms_web_image.sql/ -o

2018/03/27 14:05:49.429981 loader.go:76: [INFO] restoring.database[isms] 2018/03/27 14:05:49.430090 loader.go:87: [INFO] working.table[isms.isms_web_image] 2018/03/27 14:05:49.430356 loader.go:102: [INFO] drop(overwrite.is.true).table[isms.isms.isms_web_image] panic: Table 'isms_web_image' already exists (errno 1050) (sqlstate 42S01)

it's table[isms.isms.isms_web_image]? in fact table is [isms.isms_web_image]

BohuTANG commented 6 years ago

@long904 Thanks for the figure out. The master branch should be work, the change commit id: https://github.com/xelabs/go-mydumper/commit/b983fd2d645d91c9f41de8da56a138999308aa4f

long904 commented 6 years ago

good. It's work. thank you