volatiletech / sqlboiler

Generate a Go ORM tailored to your database schema.
BSD 3-Clause "New" or "Revised" License
6.69k stars 539 forks source link

How to solve this error ? Unable to execute setup: failed to wait for mysqldump command: exit status 2 #95

Closed bxcodec closed 7 years ago

bxcodec commented 7 years ago

Hi, First of all, thank you for making a great tools like this :+1:

So, what am i using here are

sqlboiler : 2.17 mysql : 5.7 go1.7.3

When i'm generating the models, its run well. But when i'm doing the test for the models go test ./models it's return : Unable to execute setup: failed to wait for mysqldump command: exit status 2

How could this happen ? on what condition ? and how to solve it ?

I already read your README.md , but got nothing.

Thanks,

nullbio commented 7 years ago

Hi @bxcodec. Our test suite pipes out to mysqldump to create a temporary duplicate of your database to run against. From what I can see online, error code 2 is frequently the result of permission problems. The first place to look would be to ensure the user configured in your sqlboiler.toml has permissions to dump your database. Your user should have superuser privileges.

bxcodec commented 7 years ago

I read from other source. mysqldump can done with login as root user in "mysq"l. But i don't know how to do that in sqlboiler ?

I already set the user for the DB as root in my *.toml configuration file as like belows :

blacklist=["migrations", "other"]
schema="MyData"
[mysql]
dbname="MyData"
host="localhost"
port=3306
user="root"
pass="password"
sslmode="false"

Any idea ?

nullbio commented 7 years ago

All you should need to do is supply a user with the necessary permissions in your sqlboiler.toml. If you run the following from the cmd line what happens:

mysqldump --no-data --user=root --password MyData

Does this command work for you?

bxcodec commented 7 years ago

Well, now i know where is my problem. It's not because the permission needs. But because my Database is not well formed. I mean, I have several view tables that missing the references table/column. So I remove the view tables that caused error. I realize it after doing your command :

mysqldump --no-data --user=root --password MyData

Thanks for your help. :+1: