gpt4 book ai didi

javascript - JavaScript 可以连接 MySQL 吗?

转载 作者:行者123 更新时间:2023-11-29 23:40:02 25 4
gpt4 key购买 nike

JavaScript可以连接MySQL吗?如果是这样,怎么办?

最佳答案

如果没有某种桥接器,客户端 JavaScript 无法访问 MySQL。但上面关于 JavaScript 只是一种客户端语言的大胆说法是不正确的——JavaScript 可以运行客户端和服务器端,就像 Node.js 一样。

Node.js 可以通过类似 https://github.com/sidorares/node-mysql2 的方式访问 MySQL

您还可以使用 Socket.IO 开发一些东西

您的意思是问客户端JS应用是否可以访问MySQL?我不确定这样的库是否存在,但它们是可能的。

编辑:自撰写以来,我们现在有 MySQL Cluster :

The MySQL Cluster JavaScript Driver for Node.js is just what it sounds like it is – it’s a connector that can be called directly from your JavaScript code to read and write your data. As it accesses the data nodes directly, there is no extra latency from passing through a MySQL Server and need to convert from JavaScript code//objects into SQL operations. If for some reason, you’d prefer it to pass through a MySQL Server (for example if you’re storing tables in InnoDB) then that can be configured.

关于javascript - JavaScript 可以连接 MySQL 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26204313/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com