gpt4 book ai didi

javascript - JavaScript 可以连接 MySQL 吗?

转载 作者:IT老高 更新时间:2023-10-28 12:42:17 29 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/3020751/

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