Why is Mariadb behaving differently when access it via PuTTY or via R?

112 Views Asked by At

Rephrasing a previous question. I am trying to understand why I can get access to Mariadb via SSH over PuTTY but not over R. I'm using Windows 11 v. 22H2; server is hosted with cpanel.

Opening the connection over PuTTY, I can log in Mariadb using

mysql -u USER -p;

And from there I can show databases; and perform other SQL queries.

However, from R, after connecting via SSH, I cannot open a connection to Mariadb. In R, this fails:

mysqlconnection = dbConnect(RMySQL::MySQL(),
                            host='localhost',
                            user='USER',
                            password='PW')

With either "cannot connect to server" or "host is not allowed to connect to this MariaDB server)

NOTE: I'm working on contacting the right ppl in order to add a user as described in Host 'xxx.xx.xxx.xxx' is not allowed to connect to this MySQL server ... but I don't even understand WHY I need to do it since it works in PuTTY, using the exact same credentials.

I also tried to connect using

ssh_exec_wait(ssh_connection, command = 'mysql -u USER -p' )

worst case scenario R crashes; best case scenario the console prompts for a password but I cannot figure how to input it (yes, I tried typing it in the console an pressing Enter. Doesn't do anything.) I receive messages that R is responding to OpenSSH's keepalive.

The whole message:

channel_open: Creating a channel 43 with 64000 window and 32768 max packet
ssh_packet_global_request: Received SSH_MSG_GLOBAL_REQUEST packet
ssh_packet_global_request: UNKNOWN SSH_MSG_GLOBAL_REQUEST [email protected], want_reply = 0
ssh_packet_global_request: Invalid SSH_MSG_GLOBAL_REQUEST packet
ssh_packet_ignore_callback: Received SSH_MSG_DEBUG packet
ssh_packet_channel_open_conf: Received a CHANNEL_OPEN_CONFIRMATION for channel 43:0
ssh_packet_channel_open_conf: Remote window : 0, maxpacket : 32768
channel_rcv_change_window: Adding 2097152 bytes to channel (43:0) (from 0 bytes)
channel_request: Channel request exec success
grow_window: growing window (channel 43:0) to 1280000 bytes
Enter password: channel_rcv_request: Responding to Openssh's keepalive

So, I am trying to learn and understand why I can connect with PuTTY, but not R?

1

There are 1 best solutions below

3
mat.viguier On

Are you sure that you're db server is listenning you'r R client ? mysql native client is probably rputed to a local socket when R is not.