Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MySQL variable assignments - Fixed #5 #6

Merged
merged 1 commit into from
Dec 28, 2017

Conversation

kesuskim
Copy link
Contributor

I couldn't say I fix all of cases, but I can dump my production database with this PR.

@JamesStewy
Copy link
Owner

Hi. Thanks for your PR.

I am not particularly familiar with the ins and outs of MYSQL and, as a result, the changes you have made. Would you mind, either here or in #5, briefly describing the issue and what you have changed to fix it.

Thanks.

@kesuskim
Copy link
Contributor Author

Disclaimer: I don't know very deep bottom of MySQL, so I may be wrong, correct me if I do.

This PR is for adding some SQL statements to output of mysqldump, which is I guess related to some global variable MySQL uses internally.

As I had tested your package as is, I could backup my production database, but couldn't restore using it, saying 'foreign key constraint' error something. But I could backup & restore using mysqldump official program, so I compared both results; one from mysqldump, one from this package.

I could see there was significant difference, which is related to some SQL statements. It goes like this;

/*!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 */;

It is some global variable set statements before restore works, and mainly doing some preparation; set character set for client, character set for result, collation connection, set time_zone into UTC, disable unique constraint checks, disable foreign key constraint checks, some things like that.

Such SQL statements may be different based on their database setting, but I assumes at least many recent MySQL can be dumped using this setting (Possibly Timezone can be different if you do not use UTC, and also character set if you do not use UTF8, but other cases is quite common one).

@JamesStewy JamesStewy merged commit 417d97b into JamesStewy:master Dec 28, 2017
BrandonRoehl added a commit to BrandonRoehl/go-mysqldump that referenced this pull request Jan 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants