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

Unexpected behaviour: granting privileges to the runtime user as opposed to the supplied MySQL user #26

Open
lchski opened this issue Dec 6, 2017 · 5 comments

Comments

@lchski
Copy link
Contributor

lchski commented Dec 6, 2017

Command ran: tribble --user MYSQL_USER --password MYSQL_USER_PASSWORD create_db (subbing MYSQL_USER and MYSQL_USER_PASSWORD for actual values).

Expected behaviour: database would be created.

Actual behaviour: SQLAlchemy error 1133, "Can't find any matching row in the user table") [SQL: 'GRANT ALL PRIVILEGES ON spending.* to lucas@localhost;'


It looks like the create_db command grants privileges for the created table to the runtime user as opposed to the user provided by the --user flag (relevant line of code). I’d expect it to use the value of the --user flag as opposed to the runtime user. (On my machine, I’m using the root MySQL user as opposed to one named with my user account, so I’d expect it to grant privileges for the spending table to the root user that I pass in, rather than my runtime username.)

If this is expected behaviour, to be granting permissions to the runtime username instead of the MySQL username, we should document that. Otherwise, we should modify the behaviour. I also don’t altogether understand the distinction between the user provided in --user and the one provided in --runtime-user; clarifying that could clear this up.

@JasonMWhite
Copy link
Member

The intended behaviour is:

  • --user defines the user that will be used to login to the database. Under normal conditions, this would be the user's local username, e.g. the output of whoami.
  • When creating the database for the first time, the user --user jason doesn't exist in the database. Instead, the user root is usually the administrative user. The --runtime-user argument is meant to define & permit the user jason to query/modify the tables in the spending schema

Here's how I ran it:

tribble --user root --password my_password create_db
tribble init_db

This logged in as root, created the database spending (the default schema name), created the user jason (the result of whoami), and gave jason full permissions to the spending schema.
The second command logged in as jason (the default), and created the necessary tables in the spending schema.

I added some additional context to the command help last night, e.g. tribble create_db --help. Also added some documentation to tribble --help to point users to the fact that you can ask for help on subcommands like that.

Suggestions?

@lchski
Copy link
Contributor Author

lchski commented Dec 6, 2017

Interesting! When I run tribble --user root --password [password] create_db, it gives me this error: 1133, "Can't find any matching row in the user table") [SQL: 'GRANT ALL PRIVILEGES ON spending.* to lucas@localhost;'

Looks like the step where it creates the lucas user (or whatever the value of --runtime-user is) isn’t happening.

@JasonMWhite
Copy link
Member

That's great feedback - likely I created the user manually at some point and forgot to script it! I'll look into this ^^

@xander-miller
Copy link
Contributor

I created the xander manually MySQL before I started. It used the existing xander user to create the database. I didn't get the error Lucas is getting so I think your assessment of the bug is correct, Jason.

@lchski
Copy link
Contributor Author

lchski commented Dec 13, 2017

Looking at the script, I think that’s right. The only mention of the runtime_user is in the GRANT ALL PRIVILEGES line, nothing to create it.

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

No branches or pull requests

3 participants