2

I have a mysql running. I can access it with

mysql -h 127.0.0.1 -u root -P 8009 -p

(password requested)

Now I want to make requests with curl :

curl 127.0.0.1:8009 ????  

I need to pass the password and some simple commands (INSERT in one database)

Is it possible/ how to do that ?

EDIT : Since it seems impossible, I broaden the scope of the question.

I'm open to wget or whatever to makes simple commands in a mysql base without installing specific utilities (mysql itself, python packages, etc.). So using commonly available commands in bash.

I have no real control on the environment from which I will make the requests.

3
  • 2
    This smells like an XY-problem: meta.stackexchange.com/a/66378 In short: There's no nice/neat way to speak MySQLs protocol with easy tools, it's a binary protocol optimized for efficiency. If really neccessary, install a webserver on the MySQL server (or another host) which will take HTTP(S)-requests (from curl, wget, etc.) and send them to the database. – Tobias Mädel May 4 at 20:00
  • @Tobias Mädel My X-problem is : I want to create a Milvus-mysql docker compose. But the milvus container has to wait that mysql is not only up but to have created a database "milvus". And the milvus docker has not "mysql" in it. – Laurent Claessens May 5 at 8:08
  • @Tobias Mädel Anyway, the Y problem is interesting by itself because, for testing/debug purposes, it can be handy to make "curl ..." without installing mysql on the client side. – Laurent Claessens May 5 at 8:09
3

You can't.

curl is a HTTP client. MySQL doesn't use the HTTP protocol.

There was apparently a plugin that added a HTTP API, but the MySQL Labs page says this:

These binaries were created by MySQL testing servers.

They are NOT FIT FOR PRODUCTION.

They are provided solely for testing purposes, to try the latest bug fixes and generally to keep up with the development.

  • Please, DO NOT USE THESE BINARIES IN PRODUCTION.

So you're out of luck.

2
  • Thank for the answer. In fact I'm not totally stuck to curl. I edited the question to be less specific. – Laurent Claessens May 4 at 11:21
  • @LaurentClaessens MySQL uses a proprietary protocol. You will need MySQL-specific, or at least database-specific, tools. – gronostaj May 4 at 11:33
3

Using password is only possible in the browser-based REST API for MySQL Cloud Service.

It does not apply to your case - the protocol to communicate with MySQL is not HTTP, so you cannot use an HTTP client like cURL.

2
  • Thank for the answer. In fact I'm not totally stuck to curl. I edited the question to be less specific. – Laurent Claessens May 4 at 11:21
  • 2
    You can't get away from using a MySQL client of some kind. – harrymc May 4 at 13:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.