How to connect to MySQL server from browser using javascript?

I learned that I need to dig in the direction of a WebSocket or a raw socket, but I don’t find any information about it.

Where to start?

This is not a duplicate, as the author of another question came up with the option through the PHP bridge. It does not suit me.

  • Possible duplicate question: JavaScript + MySql? - newman
  • What does not work with server scripts? - newman
  • See below .. - Mik

1 answer 1

WebSocket does not help you. raw socket is more to the point. But in essence, you will need to implement the mysql client. The protocol is binary there and I fully admit that it is possible to do this. But in any case, the number of people needed for this month is forced to think: "Why?"

You can leave the security question overboard - since this is JavaScript - then find out the connection parameters to your server - this will be a matter of five to ten minutes.

Therefore, I would recommend starting with using a server-side programming language — to create scripts with which your javascript application can interact via WebSocket or via AJAX.

  • Deployment, please answer for raw socket. Where? How? Naturally, I know about CRUD, RPC, REST, etc. Pribluda, it does not fit. Briefly: there is a certain theoretical editor in javascript, it is very kind and wants to provide the user with auto completion and selection of tables and fields. To do this, it asks for data access to the database. This may be localhost @ root, for example. The issue of security is only a matter of user confidence. At the expense of man-hours: perhaps the minimum that I need, and does not require such serious resources. - Mik
  • There is nothing special to expand - find the source code of the client library for MySQL and rewrite them to javascript. - newman
  • The API for the raw socket is not found, that's what's the matter. for example, there is a specification: w3.org/2012/sysapps/tcp-udp-sockets , but it does not work in a fox. - Mik
  • @Mik, and this is another point in the fact that it is realizable so far only theoretically. - newman
  • one
    @Mik in chrome in the form of an experimental API seems to be as it is. - newman