Home  >  Q&A  >  body text

Does JavaScript support MySQL database connections?

<p>Can JavaScript connect to MySQL? If so, how? </p>
P粉555682718P粉555682718426 days ago453

reply all(2)I'll reply

  • P粉921165181

    P粉9211651812023-08-21 13:56:07

    Client-side JavaScript cannot access MySQL directly unless there is some kind of bridge. But the statement in the bold statement above that JavaScript is only a client-side language is incorrect - JavaScript can run both client-side and server-side, such as Node.js.

    Node.js can access MySQL through a method similar to https://github.com/sidorares/node-mysql2.

    You can also develop something using Socket.IO.

    Do you want to ask whether the client JS application can access MySQL? I'm not sure if such a library exists, but it's possible.

    EDIT: Since writing this we now have MySQL Cluster:

    reply
    0
  • P粉295728625

    P粉2957286252023-08-21 00:43:15

    No, JavaScript can not directly connect to MySQL. But you can mix JS with PHP to do so.

    JavaScript is a client-side language, while your MySQL database will run on the server.

    reply
    0
  • Cancelreply