crypto.js:74
this._handle.update(data, encoding);
^
TypeError: Data must be a string or a buffer
at TypeError (native)
at Hash.update (crypto.js:74:16)
at sha1 (/mnt/projects/Nodejs/develda/node_modules/mysql2/lib/auth_41.js:30:8)
at Object.token [as calculateToken] (/mnt/projects/Nodejs/develda/node_modules/mysql2/lib/auth_41.js:64:16)
at new HandshakeResponse (/mnt/projects/Nodejs/develda/node_modules/mysql2/lib/packets/handshake_response.js:25:24)
at ClientHandshake.sendCredentials (/mnt/projects/Nodejs/develda/node_modules/mysql2/lib/commands/client_handshake.js:46:27)
at ClientHandshake.handshakeInit (/mnt/projects/Nodejs/develda/node_modules/mysql2/lib/commands/client_handshake.js:122:10)
at ClientHandshake.Command.execute (/mnt/projects/Nodejs/develda/node_modules/mysql2/lib/commands/command.js:39:20)
at Connection.handlePacket (/mnt/projects/Nodejs/develda/node_modules/mysql2/lib/connection.js:417:28)
at PacketParser.onPacket (/mnt/projects/Nodejs/develda/node_modules/mysql2/lib/connection.js:93:16)
at PacketParser.executeStart (/mnt/projects/Nodejs/develda/node_modules/mysql2/lib/packet_parser.js:73:14)
at Socket.<anonymous> (/mnt/projects/Nodejs/develda/node_modules/mysql2 /lib/connection.js:101:29)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at readableAddChunk (_stream_readable.js:176:18)
at Socket.Readable.push (_stream_readable.js:134:10)
at TCP.onread (net.js:547:20)
当我尝试使用node_modules / .bin / sequelize db:migrate
进行迁移时,我收到此错误我认为mysql2包会导致此错误
我很感谢您的帮助
答案 0 :(得分:4)
首先,请确保您的config.json 不包含任何未加引号的值,例如此示例中的密码:
create table #tmp1
(
LicenseID int,
CompanyWindowId int,
CompanyCount int
)
GO
create table #tmp2
(
LicensedCompanyID int identity,
CompanyWindowId int,
CompanyID int,
LicenseID int
)
GO
insert into #tmp1 values (9,9,5),(12,9,2)
insert into #tmp2 (CompanyWindowId,CompanyID) values (9,10),(10,12),(10,14),(10,15),(10,16),(10,17),(10,18)
SELECT * from #tmp2
declare @licenseID int
declare @count int=1
declare @count2 int=1
declare @recordcount int
declare @CompanyCount int
select @recordcount=count(1) from #tmp1
WHILE @count2<=@recordcount
BEGIN
select @licenseID=LicenseID,@CompanyCount=CompanyCount FROM (select *, row_number() over (order by licenseID) RID from #tmp1)T where RID=@count2
SET @count=1
WHILE @CompanyCount>=@count
BEGIN
SET ROWCOUNT 1
UPDATE #tmp2 SET LicenseID=@LicenseID WHERE LicenseID IS NULL
SET @count+=1
END
SET @count2+=1
END
SET ROWCOUNT 0
SELECT * from #tmp2
drop table #tmp1
drop table #tmp2
如果这不能解决你的问题并且你有充分的理由相信它与mysql2包有关,请尝试将你的sequelize包降级到v3并使用mysql而不是mysql2
答案 1 :(得分:0)
如果您使用命令&#34; sequelize init &#34;要初始化项目,那么你应该检查你的config.json.Because默认情况下&#34; 端口&#34;字段不包括在内。 同时,请确保您的 config.json 在此示例中不包含任何未加引号的密码。
{
"my_env": {
"username": "root",
"password": 1234,
"database": "my_db",
"host" : "localhost",
"dialect" : "mysql"
}
}