Adonis (nodejs) Migration mysql error: 1045

Asked

Viewed 264 times

-1

Experiencing an error mysql reports when running a migration with Adonis (I’m starting in the nodejs world).

The application runs smoothly on my machine, when passing it to the server that in the future will be the production one, I try to run the migration with Adonis:

adonis migration:run

And get this output:

<code>
# adonis migration:run
{ Error: ER_ACCESS_DENIED_ERROR: Access denied for user 'repair'@'localhost' (using password: YES)
at Handshake.Sequence._packetToError ([...]/node_modules/mysql/lib/protocol/sequences/Sequence.js:47:14)
at Handshake.ErrorPacket ([...]/node_modules/mysql/lib/protocol/sequences/Handshake.js:123:18)
</code>

And it ends like this:

<code>
code: 'ER_ACCESS_DENIED_ERROR',
errno: 1045,
sqlMessage:
'Access denied for user \'repair\'@\'localhost\' (using password: YES)',
sqlState: '28000',
fatal: true }
</code>

Only that I can, on this server, enter mysql with the user in question: "Repair". The file ". env", if I change DB_HOST to the server address I get a "Conection Refused" /"ECONNREFUSED". The user password in the file ". env" is correct.

The file . env:

<code>
HOST=[endereço/ip do servidor]
PORT=3333
NODE_ENV=development
APP_NAME=AdonisJs
APP_URL=http://${HOST}:${PORT}
CACHE_VIEWS=false
APP_KEY=[chave]
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_USER=repair
DB_PASSWORD=[senha]
DB_DATABASE=repair
HASH_DRIVER=bcrypt
</code> 

The error "1045" I get when DB_HOST=localhost. I’ve already updated the user to @'%'... Getting the same answer.

2 answers

0

It was an invalid character in the password.

1] I changed the user password in the database 2] I changed Nodejs to use the new password

Solved.

0

Taking into account the information you posted and considering that Mysql is installed on the same server that is running your application, I would consider some tests related to the database:

Access mysql via command line with the user "Repair" and the password you are using on . application env, if successful in accessing make some changes to the "Repair" database (create table/ Insert / update) only to test this user’s privileges. If you do not get the problem may be related to privileges.

mysql -u repair -p 'sua senha';

Once verified the access and the user privileges and everything being working in mysql I would change to test in the file . env of your application the address of the database:

/* de */
        DB_HOST=localhost

/*para*/

        DB_HOST=127.0.0.1

Try to run Migration again.

  • I can log into the server, access the database with the user, create tables, insert etc... (the server is hosted along with the backend application). Read your post, I made changes to . env and it hasn’t worked yet.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.