bodhilogic
I want to establish a ‘web-safe’ user for my MySQL database (i.e. one that only has select, create, update and delete permissions).
If I drop my web-safe user from the database, I get this error which is totally expected because I have no such user in the database:
[error] MyXQL.Connection (#PID<0.287.0>) failed to connect: ** (MyXQL.Error) (1045) (ER_ACCESS_DENIED_ERROR) Access denied for user 'web'@'localhost' (using password: YES)
If I then go and create the ‘web-safe’ user in the database, even assigning the user with full grant privileges, I get a new error:
[error] MyXQL.Connection (#PID<0.275.0>) failed to connect: ** (MyXQL.Error) (1045) (ER_ACCESS_DENIED_ERROR) Access denied for user 'root'@'localhost' (using password: YES)
Say wha???
Why, now that it has the web@localhost user defined, is it attempting to connect using the root@localhost user?
My repo.ex file is the only place any connection information is established and I am definitely not attempting to use the root database user for any of my queries (i.e. override my connection settings).
If I have my app deliberately specify the root@localhost user for it’s connection information, then all works well but that totally defeats the purpose and reason for wanting to use a ‘web-safe’ database user.
Please help… I want to get this app deployed ASAP.
Thanks for your time and troubles.
Trending in Questions
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixir-ls
- #ai
- #elixirconf-us
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
hauleth
Show us your config files.
bodhilogic
config.exs
dev.exs
prod.exs
repo.ex
And yes, the encryption routines work fine - I use them all the time and they especially work for this app when I am running the app on my source machine.
wojtekmach
MyXQL defaults
:usernametoSystem.get_env("USER"), but you are explicitly passing:usernameoption so it’s unclear to me what’s going on. What is the system user you’re starting elixir process with? If you could reproduce it in a minimal project please open up an issue in myxql repo and I’ll take a look.bodhilogic
I noticed that same thing the other day so I went through the trouble of setting up the same environment variables MyXQL is looking for in their source code (HOST, USER and MYSQL_PWD) , but I thought they were daft names and wanted to use my own.
I’ll go back to try using their environment variable names and see if that fixes my problem - I’ll let you know the results.
bodhilogic
No luck. I’m now using the environment variables MyXQL is expecting and I still get this error:
wojtekmach
Note you don’t need to set the environment variables if you are setting the repo configuration. Could you paste the output (without secrets) of:
? Also please paste your myxql, ecto, and ecto_sql versions, and make you sure you tried on the latest myxql release (although I don’t think we ever had such bug)
bodhilogic
Well, that didn’t go well.
First, I had repo.ex assign the user and password from the environment variables “USER” and “MYSQL_PWD” and when running the app, I got a bevy of errors.
I then set the show_sensitive_data_on_connection_error flag to true to see what it was really complaining about. It report that :username is missing.
So then, in the repo.ex file, I directly assigned the username and password (without using environment variables) and now we are back to this error:
(and I am not using ‘root’ as the username!!)
I tried to give you the results of
iex> MyApp.Repo.config()but iex complains thatmodule Ecto.Repo is not loaded and can't be foundso I gave up.myxql version is 0.2.10
ecto version is 3.1.4
ecto_sql version is 3.1.2
BTW: I appreciate your time and patience!
wojtekmach
if this evaluates to
nil, which is my guess, then you’d get the:username is missingerror. If that’s the case the error message is arguably a little bit misleading, the username was set it’s just it’s set to nil which is not allowed.If you set
:usernamein the config file, but you still have the code mentioned above, the code takes precedence.Could you hardcode username in the
repo.exand see if that works?bodhilogic
That’s exactly what I did (set it in the repo.ex file) and it still wants to connect to the root db user:
bodhilogic
But you bring up a good point - I should add some error trapping in there to ensure that I’m not trying to use
nilvalues!