gpt4 book ai didi

mysql - 使用 Angular 访问数据库

转载 作者:可可西里 更新时间:2023-11-01 07:08:41 24 4
gpt4 key购买 nike

是否可以在 Angular 框架中访问 MySQL 数据库,或者像其他 Javascript 一样不安全,我需要发布到 PHP 页面以从数据库中检索 data/json

最佳答案

1- 是否可以在 Angular 框架中访问 MySQL 数据库?

这个问题不是特定于 Angular ,但是是可能的,因为 MySQL 5.7 可以通过 HTTP 在 MySQL 中插入、更新和删除记录。像这样

http://127.0.0.1:8080/sql/myhttp/SELECT+name_first,+name_last+FROM+names 
``` [refer here][1]

> Hence you can interact with MySQL directly with any HTTP client with
> out any middle-ware.

By HTTP Client I mean Curl,Wget or any Http library/API of any language (ajax,request,fetch,axios ... for JavaScript/node)

2 - Would that be insecure like other JavaScript?

Again not JavaScript specific, But **Yes it's insecure(not recommended)** to directly interact with the database from the client.
Why?
You need to handle database security issues like SQL Injection from the client side (angular in this case). It's is very inconvenient to do that.


[1]: https://scriptingmysql.wordpress.com/2015/01/15/mysql-5-7-labs-and-the-http-plugin-inserting-updating-and-deleting-records-in-mysql-via-http/

> I do recommend to always have database access middle-ware
> (php,node,python ...) than interacting from client side

关于mysql - 使用 Angular 访问数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46644574/

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