我有这个基本的代码应该起作用,但是没有。可能是什么问题?
import mariadb from 'mariadb';
const fn = () => {
mariadb.createConnection({
host: 'localhost',
port: 3306,
user: 'test',
password: 'test',
debug: true,
}).then(conn => {
conn.query('SELECT "Hello there" as Kenobi')
.then(result => result)
.then(conn.destroy());
});
};
fn();
使用debug:true,我只会得到此输出,而没有其他结果:
<== conn:-1 Handshake.parseHandshakeInit (0,106)
6A 00 00 00 0A 35 2E 35 2E 35 2D 31 30 2E 31 2E j....5.5.5-10.1.
33 34 2D 4D 61 72 69 61 44 42 2D 30 75 62 75 6E 34-MariaDB-0ubun
74 75 30 2E 31 38 2E 30 34 2E 31 00 51 00 00 00 tu0.18.04.1.Q...
41 2E 5E 72 43 36 25 52 00 FF F7 2D 02 00 3F A0 A.^rC6%R...-..?.
15 00 00 00 00 00 00 00 00 00 00 52 24 5A 7B 7C ...........R$Z{|
7B 76 5C 4D 49 67 4B 00 6D 79 73 71 6C 5F 6E 61 {v\MIgK.mysql_na
74 69 76 65 5F 70 61 73 73 77 6F 72 64 00 tive_password.
==> conn:81 Handshake.parseHandshakeInit(0,83)
4F 00 00 01 02 A3 AE 00 00 00 00 40 E0 00 00 00 O..........@....
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 66 6D 73 00 14 33 AF 12 C5 84 43 95 ....fms..3....C.
85 51 6B D4 34 2B F0 20 6D 73 92 34 75 6D 79 73 .Qk.4+. ms.4umys
71 6C 5F 6E 61 74 69 76 65 5F 70 61 73 73 77 6F ql_native_passwo
72 64 00 rd.
<== conn:81 Handshake.handshakeResult (0,7)
07 00 00 02 00 00 00 02 00 00 00 ...........
==> conn:81 Query(0,35)
1F 00 00 00 03 53 45 4C 45 43 54 20 22 48 65 6C .....SELECT "Hel
6C 6F 20 74 68 65 72 65 22 20 61 73 20 4B 65 6E lo there" as Ken
6F 62 69 obi
好像完全在查询中停止了吗?
我可以从命令行访问数据库:
$ mysql -u test -ptest
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 83
Server version: 10.1.34-MariaDB-0ubuntu0.18.04.1 Ubuntu 18.04
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> select "Hello there" as Kenobi;
+-------------+
| Kenobi |
+-------------+
| Hello there |
+-------------+
1 row in set (0.00 sec)
MariaDB [(none)]>
我尝试了各种方式对其进行记录,但是基本上query()
之后的所有内容都消失了。没有err
,try..catch
不会为其输出任何内容,result
为空,并且基本上就好像它在我调用query()的那一刻停止执行任何操作一样。
$节点-v v8.10.0