Skip to content

[AdonisJS 5] Error Access denied for user for driver mysq and mysq2 #3539

Answered by tomgobich
andre-ab asked this question in Help
Discussion options

You must be logged in to vote

Env.get() takes a lookup key as the first argument that it'll use to grab a value from the .env file. You can use the second argument for fallback values, though I'd recommend the below over that.

What you want to do is add the values you placed inside your MySQL config inside the .env file as the following:

DB_CONNECTION=mysql
MYSQL_HOST=localhost
MYSQL_PORT=3306
MYSQL_USER=aldisseia
MYSQL_PASSWORD=mid800
MYSQL_DB_NAME=mydb

The premise of environment variables is to keep things like this secret and outside of the code. The .env file shouldn't be committed to GitHub or any other repository.

Once you've updated your .env file to the above, reset your MySQL config back to how it initially …

Replies: 3 comments 7 replies

Comment options

You must be logged in to vote
3 replies
@andre-ab
Comment options

@tomgobich
Comment options

@andre-ab
Comment options

Answer selected by RomainLanz
Comment options

You must be logged in to vote
3 replies
@andre-ab
Comment options

@galaczi
Comment options

@andre-ab
Comment options

Comment options

You must be logged in to vote
1 reply
@WeyIin
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
4 participants