There is a module in nginx that has this function. (Extensions in previous articles are called modules here, and will be called modules in the future. The module may be more accurate, because the extension is a separate file, and the module is embedded in the main file) , this module is called drizzle-nginx-module
It’s not easy to compile this
Download the drizzle library first
Compilation and configuration options:
Copy code The code is as follows:
./configure --without-server
make libdrizzle-1.0
make install-libdrizzle-1.0
The next step is the output, http directly outputs the json string , what should I do? I need to download another module. There are too many modules to download.
https://github.com/openresty/rds-json-nginx-module
The final configuration options are as follows:
Copy code The code is as follows:
./configure --prefix=/opt/nginxrw --with-http_gzip_static_module --with-http_stub_status_module --with-http_ssl_module --add- module=/data/src/lua-nginx-module-0.9.8 --add-module=/data/src/ngx_devel_kit-0.2.19 --add-module=/data/src/drizzle-nginx-module-0.1 .7 --add-module=/data/src/rds-json-nginx-module-master
When nginx is finally started, it may report that the drizzle shared library cannot be found. You can see Download the configuration file: /etc/ld.so.conf. After changing the configuration, remember to use lddconfig to re-validate it.
How to use it
First, in nginx Declare a mysql server in the http module
Copy code The code is as follows:
upstream backend {
Drizzle_server 172.21.107.247:3306 dbname=oneplus_user_sso password= user=root protocol= mysql;
}
The next step is to declare location processing
Copy code The code is as follows:
Location /mysql {
select * from t_user limit 1';
drizzle_query $my_sql;
drizzle_pass backend;
drizzle_connect_timeout 500ms; # default 60s
drizzle_send_query_ timeout 2s; # default 60s
drizzle_recv_cols_timeout 1s ; # default 60s
drizzle_recv_rows_timeout 1s; # default 60s
rds_json on; ://172.21.107.174/mysql,
can output a user's information, and the format is json
The above is the detailed content of How does Nginx implement asynchronous access to mysql?. For more information, please follow other related articles on the PHP Chinese website!

MySQLstringtypesimpactstorageandperformanceasfollows:1)CHARisfixed-length,alwaysusingthesamestoragespace,whichcanbefasterbutlessspace-efficient.2)VARCHARisvariable-length,morespace-efficientbutpotentiallyslower.3)TEXTisforlargetext,storedoutsiderows,

MySQLstringtypesincludeVARCHAR,TEXT,CHAR,ENUM,andSET.1)VARCHARisversatileforvariable-lengthstringsuptoaspecifiedlimit.2)TEXTisidealforlargetextstoragewithoutadefinedlength.3)CHARisfixed-length,suitableforconsistentdatalikecodes.4)ENUMenforcesdatainte

MySQLoffersvariousstringdatatypes:1)CHARforfixed-lengthstrings,2)VARCHARforvariable-lengthtext,3)BINARYandVARBINARYforbinarydata,4)BLOBandTEXTforlargedata,and5)ENUMandSETforcontrolledinput.Eachtypehasspecificusesandperformancecharacteristics,sochoose

TograntpermissionstonewMySQLusers,followthesesteps:1)AccessMySQLasauserwithsufficientprivileges,2)CreateanewuserwiththeCREATEUSERcommand,3)UsetheGRANTcommandtospecifypermissionslikeSELECT,INSERT,UPDATE,orALLPRIVILEGESonspecificdatabasesortables,and4)

ToaddusersinMySQLeffectivelyandsecurely,followthesesteps:1)UsetheCREATEUSERstatementtoaddanewuser,specifyingthehostandastrongpassword.2)GrantnecessaryprivilegesusingtheGRANTstatement,adheringtotheprincipleofleastprivilege.3)Implementsecuritymeasuresl

ToaddanewuserwithcomplexpermissionsinMySQL,followthesesteps:1)CreatetheuserwithCREATEUSER'newuser'@'localhost'IDENTIFIEDBY'password';.2)Grantreadaccesstoalltablesin'mydatabase'withGRANTSELECTONmydatabase.TO'newuser'@'localhost';.3)Grantwriteaccessto'

The string data types in MySQL include CHAR, VARCHAR, BINARY, VARBINARY, BLOB, and TEXT. The collations determine the comparison and sorting of strings. 1.CHAR is suitable for fixed-length strings, VARCHAR is suitable for variable-length strings. 2.BINARY and VARBINARY are used for binary data, and BLOB and TEXT are used for large object data. 3. Sorting rules such as utf8mb4_unicode_ci ignores upper and lower case and is suitable for user names; utf8mb4_bin is case sensitive and is suitable for fields that require precise comparison.

The best MySQLVARCHAR column length selection should be based on data analysis, consider future growth, evaluate performance impacts, and character set requirements. 1) Analyze the data to determine typical lengths; 2) Reserve future expansion space; 3) Pay attention to the impact of large lengths on performance; 4) Consider the impact of character sets on storage. Through these steps, the efficiency and scalability of the database can be optimized.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Chinese version
Chinese version, very easy to use

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version
Useful JavaScript development tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment
