Skip to content

Upon connection, sometimes (randomly) it tries to use wrong user host part #3808

@afwbkbc

Description

@afwbkbc

Basic example:

		this.connection = await MYSQL.createConnection(
			'mysql://root:password@localhost:3306/test'
		);

It connects fine, but then - it should login as 'root'@'localhost', right?
Instead I get Error: Access denied for user 'root'@'10.0.0.33' (using password: YES)
Started happening after PC reboot, I checked ifconfig and 10.0.0.33 just happened to be listed first:

$ ifconfig | grep inet
inet 10.0.0.33 netmask 255.255.255.0 broadcast 10.0.0.255
inet 127.0.0.1 netmask 255.0.0.0
inet 10.8.23.3 netmask 255.255.255.0 destination 10.8.23.3

So my guess is that's why it got picked up as host part of user.
Why is it a problem? Because it forces to create all users as 'user'@'%' just in case mysql2 picks wrong user host part. It may lower security in some cases and can be inconvenience when you have to change 'localhost' to '%' for all users and reapply all grants on a big DB.

I tried googling for easy solution but there's nothing. Is there any easy fix?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions