question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[question RE: proxy example] unable to select database

See original GitHub issue

Hi. Great library!

The following output is produced by a proxy server which uses your wonderful library as both a server and a client (to a remote MariaDB database).

This test fully confirms that the observed behavior isn’t the result of anything that I added, since the same occurs in the proxy server example as taken directly from your repo.

Example from the mysql command-line client connected to the proxy:

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: mysql-proxy mariadb.org binary distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MySQL [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| mysql_proxy_test   |
| performance_schema |
| test               |
+--------------------+
5 rows in set (0.005 sec)

MySQL [(none)]> use mysql_proxy_test;
Database changed
MySQL [mysql_proxy_test]> select database();
+------------+
| database() |
+------------+
| NULL       |
+------------+
1 row in set (0.014 sec)

MySQL [mysql_proxy_test]> show tables;
ERROR 1064 (_____): No database selected
MySQL [mysql_proxy_test]>

The fundamental issue is how the mysql client executes “USE db_name;” statements. Apparently, this command isn’t sent to the proxy and, consequently, is not forwarded to the remote db connection. Instead, this connection sees: “SELECT DATABASE()”.

I can fully confirm that when the “USE db_name;” query is directly passed to the remote db connection… it works. The problem is that the mysql client doesn’t communicate this query.

Do you think this is a bug in the mysql client?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:22 (22 by maintainers)

github_iconTop GitHub Comments

1reaction
warren-bankcommented, Oct 11, 2019

not a problem… my project is just a proof-of-concept for right now… nothing mission critical. I’ll try to write a monkey patch for until it hits npm.

1reaction
warren-bankcommented, Oct 11, 2019

awesome!

after applying that fix… I retested:

  conn.on('init_db', (schemaName) => {
    conn.emit('query', `USE ${schemaName};`)
  })

…and now “USE db_name;” statements work in the mysql client

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting for RDS Proxy - AWS Documentation
Common issues and solutions · The proxy is unable to establish a database connection because the maximum connections have been reached · The...
Read more >
Frequently Asked Questions - ProxySQL
Some user has raised a question asking why will USE database always succeed in ProxySQL even when the database doesn't exist.
Read more >
4.22 Troubleshooting Problems Connecting to MySQL
After trying to connect from the client machine, use a SELECT USER() query to see how you really did connect. Then change the...
Read more >
Proxy Users!!!!!!!!!!!! - Ask TOM
the proxy user DOES have a password, the proxy user authenticates to the database "normally". ... It does NOT use the password of...
Read more >
Getting Git to work with a proxy server - Stack Overflow
Most of the answers in this question go about HTTP proxies. If you have a SOCKS proxy, see this question for the HTTP/S...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found