[MDEV-24293] All remote connections seen as Localhost by the database Created: 2020-11-26  Updated: 2020-12-04

Status: Open
Project: MariaDB Server
Component/s: Platform Windows
Affects Version/s: 10.5.4
Fix Version/s: None

Type: Bug Priority: Major
Reporter: John Cox Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Environment:

VPC on AWS, All in the Same subnet, Windows 2019 server.

Server 1
DBServer
Windows 2019 server.
Workgroup
MariaDB 10.5 server

Server 2
Application Server
Windows 2019 server
Workgroup
Client for MariaDB 10.5



 Description   

I have determined that MariaDB is seeing all DB logons as being local.
Logging onto MariaDB on server 1 from server 2 results in a connection from localhost.
I can see this by doing a query from the command line, or by using MySQL workbench from server 1.
It does not matter if I use password or named pipes, the logon is seen as local by the database, when logging on from a different computer.

MySQL workbench and HeidiSQL will not connect to the DB from server 2 to the DB.



 Comments   
Comment by Vladislav Vaintroub [ 2020-11-26 ]

this is not a very specific description.
what exactly you tried, and what are the error messages you have seen?
"I can see this by doing a query from the command line, or by using MySQL workbench from server 1."
What was the query you tried from command line, or workbench. What was the output?

here is an example of 2 root users, 1 connecting locally, and one remotely. pay attention to the column "host"

mysql -uroot --host=192.168.1.66
 
.....
mysql> show processlist;
+----+------+-----------------+------+---------+------+----------+------------------+----------+
| Id | User | Host            | db   | Command | Time | State    | Info             | Progress |
+----+------+-----------------+------+---------+------+----------+------------------+----------+
|  3 | root | localhost:64649 | NULL | Sleep   | 1009 |          | NULL             |    0.000 |
|  5 | root | workpc:63381    | NULL | Query   |    0 | starting | show processlist |    0.000 |
+----+------+-----------------+------+---------+------+----------+------------------+----------+
2 rows in set (0.00 sec)

As you see, one user is from localhost, another one (current) , is from workpc

mysql> select user();
+-------------+
| user()      |
+-------------+
| root@workpc |
+-------------+
1 row in set (0.01 sec)
 
mysql> select current_user();
+----------------+
| current_user() |
+----------------+
| root@%         |
+----------------+
1 row in set (0.00 sec)

As you see, it is a remote connection, correctly identified, no localhost here

Comment by John Cox [ 2020-12-04 ]

Here is an explanation shown similar to what you presented.

MariaDB [(none)]> show processlist;
---------------------------------------------------------------------------------------------------

Id User Host db Command Time State Info Progress

---------------------------------------------------------------------------------------------------

79 root localhost:57630 NULL Sleep 17   NULL 0.000
89 test01 localhost NULL Sleep 30   NULL 0.000

---------------------------------------------------------------------------------------------------

MariaDB 10.5.4 on windows server 2019 running in AWS
Server1 is the DB server
Server2 is the client / app server

User ID 79 is logged on from server1, as host localhost
User ID 89 is logged in from server2, as host localhost, but host should be as server2
As you can see, no port number is showing either.
I have reinstalled mariadb at least 4 times

Through experimentation I have found that I must have an account setup as 'test01'@'localhost' and one for the remote system 'test01'@'server2IP'.
I cannot log on from a remote system until I have logged on from the DBserver at least once, but the DB sees it as localhost.

Test01 has never been setup to login from localhost but it does login, most likely because I setup the wildcard '%' as host, but I understand that '%' does not work for localhost;
MariaDB [(none)]> select user, host, plugin from mysql.user where user like '%test01%';
---------------------------------

User Host plugin

---------------------------------

test01 % mysql_native_password

---------------------------------

Trying to connect to localhost on the DB server this is the results.
C:\Users\Administrator>mysql -u test01 -p
Enter password: *******
ERROR 2002 (HY000): Can't connect to MySQL server on 'localhost' (10061)

Trying to connect to the DB from server2 this is the rusults.
MariaDB [(none)]> select user, host, plugin from mysql.user where user like '%test03%';
--------------------------------------------------------

User Host plugin

--------------------------------------------------------

test03 172.31.5.67 mysql_native_password
test03 ip-172-31-5-67.ec2.internal mysql_native_password

--------------------------------------------------------

C:\Users\Argoadmin>mysql -u test03 -p -P3312 -h 172.31.13.200
Enter password: *******
ERROR 1045 (28000): Access denied for user 'test03'@'localhost' (using password: YES)

Comment by John Cox [ 2020-12-04 ]

Here is an explanation shown similar to what you presented.

MariaDB [(none)]> show processlist;
---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------

MariaDB 10.5.4 on windows server 2019 running in AWS
Server1 is the DB server
Server2 is the client / app server

User ID 79 is logged on from server1, as host localhost
User ID 89 is logged in from server2, as host localhost, but host should be as server2
As you can see, no port number is showing either.
I have reinstalled mariadb at least 4 times

Through experimentation I have found that I must have an account setup as 'test01'@'localhost' and one for the remote system 'test01'@'server2IP'.
I cannot log on from a remote system until I have logged on from the DBserver at least once, but the DB sees it as localhost.

Test01 has never been setup to login from localhost but it does login, most likely because I setup the wildcard '%' as host, but I understand that '%' does not work for localhost;
MariaDB [(none)]> select user, host, plugin from mysql.user where user like '%test01%';
---------------------------------
---------------------------------
---------------------------------

Trying to connect to localhost on the DB server this is the results.
C:\Users\Administrator>mysql -u test01 -p
Enter password: *******
ERROR 2002 (HY000): Can't connect to MySQL server on 'localhost' (10061)

Trying to connect to the DB from server2 this is the rusults.
MariaDB [(none)]> select user, host, plugin from mysql.user where user like '%test03%';
--------------------------------------------------------
--------------------------------------------------------
--------------------------------------------------------

C:\Users\Argoadmin>mysql -u test03 -p -P3312 -h 172.31.13.200
Enter password: *******
ERROR 1045 (28000): Access denied for user 'test03'@'localhost' (using password: YES)

----Original Message----
From: Vladislav Vaintroub (Jira) <jira@mariadb.org>
Sent: Thursday, November 26, 2020 6:56 PM
To: jcox@algoreturns.com
Subject: [JIRA] (MDEV-24293) All remote connections seen as Localhost by the database

[ https://jira.mariadb.org/browse/MDEV-24293?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=173343#comment-173343 ]

Vladislav Vaintroub edited comment on MDEV-24293 at 11/26/20 11:55 PM:
-----------------------------------------------------------------------

this is not a very specific description.
what exactly you tried, and what are the error messages you have seen?
"I can see this by doing a query from the command line, or by using MySQL workbench from server 1."
What was the query you tried from command line, or workbench. What was the output?

here is an example of 2 root users, 1 connecting locally, and one remotely. pay attention to the column "host"

mysql -uroot --host=192.168.1.66
 
.....
mysql> show processlist;
+----+------+-----------------+------+---------+------+----------+------------------+----------+
+----+------+-----------------+------+---------+------+----------+------------------+----------+
+----+------+-----------------+------+---------+------+----------+------------------+----------+
2 rows in set (0.00 sec)

As you see, one user is from localhost, another one (current) , is from workpc

mysql> select user();
+-------------+
+-------------+
+-------------+
1 row in set (0.01 sec)
 
mysql> select current_user();
+----------------+
+----------------+
+----------------+
1 row in set (0.00 sec)

As you see, it is a remote connection, correctly identified, no localhost here

was (Author: wlad):
this is not a very specific description.
what exactly you tried, and what are the error messages you have seen?
"I can see this by doing a query from the command line, or by using MySQL workbench from server 1."
What was the query you tried from command line, or workbench. What was the output?

here is an example of 2 root users, 1 connecting locally, and one remotely. pay attention to the column "host"

C:\work\10.5\xxx\sql\Debug>mysql -uroot --host=192.168.1.66
 
.....
mysql> show processlist;
+----+------+-----------------+------+---------+------+----------+------------------+----------+
+----+------+-----------------+------+---------+------+----------+------------------+----------+
+----+------+-----------------+------+---------+------+----------+------------------+----------+
2 rows in set (0.00 sec)

As you see, one user is from localhost, another one (current) , is from workpc

mysql> select user();
+-------------+
+-------------+
+-------------+
1 row in set (0.01 sec)
 
mysql> select current_user();
+----------------+
+----------------+
+----------------+
1 row in set (0.00 sec)

As you see, it is a remote connection, correctly identified, no localhost here


This message was sent by Atlassian Jira
(v8.5.1#805001)

Comment by Vladislav Vaintroub [ 2020-12-04 ]

Apparently, the lack of ":port" after localhost in this output

89	test01	localhost	NULL	Sleep	30	 	NULL	0.000

means, that you connect using named pipe. it is possible to connect remotely with named pipe, although I would not know what it would be good for.
You probably pull protocol=pipe in the [client] section from some my.ini

named pipe connection are always "localhost", when it comes to authentication, even if you could connect remotely.

Generated at Thu Feb 08 09:28:53 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.