From d7c75f3b262058e6270d772dd655d980767a0398 Mon Sep 17 00:00:00 2001 From: Linhe Huo Date: Wed, 19 Mar 2025 11:00:00 +0800 Subject: [PATCH] docs: fix password tutorial display (#30263) --- docs/en/27-train-faq/03-password.md | 19 +++++++++---------- docs/zh/27-train-faq/03-password.md | 19 +++++++++---------- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/docs/en/27-train-faq/03-password.md b/docs/en/27-train-faq/03-password.md index f6029b5092..5acfe1e34d 100644 --- a/docs/en/27-train-faq/03-password.md +++ b/docs/en/27-train-faq/03-password.md @@ -56,7 +56,7 @@ taosdump -u user1 -pAb1\!\@\#\$\%\^\&\*\(\)\-\_\+\=\[\]\{\} -D test ``` - + In [taosBenchmark](../../tdengine-reference/tools/taosbenchmark/), note the following: @@ -79,15 +79,12 @@ When using `taosBenchmark -f `, there are no restrictions on the password Example of exporting data with user `user1`: ```shell -taosx -f 'taos://user1:Ab1!@#$%^&*()-_+=[]{}@localhost:6030?query=select * from test.t1' -t 'csv:./test.csv' +taosx -f 'taos://user1:Ab1!@#$%^&*()-_+=[]{}@localhost:6030?query=select * from test.t1' \ + -t 'csv:./test.csv' ``` Note that if the password can be URL decoded, the URL decoded result will be used as the password. For example: `taos+ws://user1:Ab1%21%40%23%24%25%5E%26%2A%28%29-_%2B%3D%5B%5D%7B%7D@localhost:6041` is equivalent to `taos+ws://user1:Ab1!@#$%^&*()-_+=[]{}@localhost:6041`. - - - - No special handling is required in [Explorer](../../tdengine-reference/components/taosexplorer/), just use it directly. @@ -246,7 +243,7 @@ async function createConnect() { console.log("Connected to " + dsn + " successfully."); return conn; } catch (err) { - console.log("Failed to connect to " + dsn + ", ErrCode: " + err.code + ", ErrMessage: " + err.message); + console.log("Connection failed with code: " + err.code + ", message: " + err.message); throw err; } } @@ -278,7 +275,7 @@ TAOS *taos = taos_connect("localhost", "user1", "Ab1!@#$%^&*()-_+=[]{}", NULL, 6 ``` - + When using passwords in REST API, note the following: @@ -288,8 +285,10 @@ When using passwords in REST API, note the following: The following two methods are equivalent: ```shell -curl -u'user1:Ab1!@#$%^&*()-_+=[]{}' -d 'show databases' http://localhost:6041/rest/sql -curl -H 'Authorization: Basic dXNlcjE6QWIxIUAjJCVeJiooKS1fKz1bXXt9' -d 'show databases' http://localhost:6041/rest/sql +curl -u'user1:Ab1!@#$%^&*()-_+=[]{}' \ + -d 'show databases' http://localhost:6041/rest/sql +curl -H 'Authorization: Basic dXNlcjE6QWIxIUAjJCVeJiooKS1fKz1bXXt9' \ + -d 'show databases' http://localhost:6041/rest/sql ``` diff --git a/docs/zh/27-train-faq/03-password.md b/docs/zh/27-train-faq/03-password.md index 7ea215999d..55f336798a 100644 --- a/docs/zh/27-train-faq/03-password.md +++ b/docs/zh/27-train-faq/03-password.md @@ -56,7 +56,7 @@ taosdump -u user1 -pAb1\!\@\#\$\%\^\&\*\(\)\-\_\+\=\[\]\{\} -D test ``` - + 在 [taosBenchmark](../../reference/tools/taosbenchmark/) 中使用需要注意以下几点: @@ -79,15 +79,12 @@ taosBenchmark -u user1 -p'Ab1!@#$%^&*()-_+=[]{}' -d test -y 使用用户 `user1` 导出数据示例如下: ```shell -taosx -f 'taos://user1:Ab1!@#$%^&*()-_+=[]{}@localhost:6030?query=select * from test.t1' -t 'csv:./test.csv' +taosx -f 'taos://user1:Ab1!@#$%^&*()-_+=[]{}@localhost:6030?query=select * from test.t1' \ + -t 'csv:./test.csv' ``` 需要注意的是,如果密码可被 URL decode,则会使用 URL decoded 结果作为密码。如:`taos+ws://user1:Ab1%21%40%23%24%25%5E%26%2A%28%29-_%2B%3D%5B%5D%7B%7D@localhost:6041` 与 `taos+ws://user1:Ab1!@#$%^&*()-_+=[]{}@localhost:6041` 是等价的。 - - - - 在 [Explorer](../../reference/components/explorer/) 中无需特殊处理,直接使用即可。 @@ -246,7 +243,7 @@ async function createConnect() { console.log("Connected to " + dsn + " successfully."); return conn; } catch (err) { - console.log("Failed to connect to " + dsn + ", ErrCode: " + err.code + ", ErrMessage: " + err.message); + console.log("Connection failed with code: " + err.code + ", message: " + err.message); throw err; } } @@ -278,7 +275,7 @@ TAOS *taos = taos_connect("localhost", "user1", "Ab1!@#$%^&*()-_+=[]{}", NULL, 6 ``` - + REST API 中使用密码时,需要注意以下几点: @@ -288,8 +285,10 @@ REST API 中使用密码时,需要注意以下几点: 以下两种方式等价: ```shell -curl -u'user1:Ab1!@#$%^&*()-_+=[]{}' -d 'show databases' http://localhost:6041/rest/sql -curl -H 'Authorization: Basic dXNlcjE6QWIxIUAjJCVeJiooKS1fKz1bXXt9' -d 'show databases' http://localhost:6041/rest/sql +curl -u'user1:Ab1!@#$%^&*()-_+=[]{}' \ + -d 'show databases' http://localhost:6041/rest/sql +curl -H 'Authorization: Basic dXNlcjE6QWIxIUAjJCVeJiooKS1fKz1bXXt9' \ + -d 'show databases' http://localhost:6041/rest/sql ```