michaelliao/itranswarp.js

init-db执行报SequelizeAccessDeniedError: ER_AC CESS_DENIED_ERROR: Access denied

ciey opened this issue · 2 comments

ciey commented

run $ node www/script/init-db.js 报错

init database...
Exec: mysql -h localhost -u root --password=123456 -e "DROP DATABASE IF EXISTS i
transwarp;"
Exec: mysql -h localhost -u root --password=123456 -e "CREATE DATABASE itranswar
p;"
Exec: mysql -h localhost -u root --password=123456 -e "GRANT SELECT, INSERT, UPD
ATE, DELETE ON itranswarp.* TO 'root'@'localhost' IDENTIFIED BY 'password';"
2018-11-05T16:19:51.408Z - info: init sequelize...
2018-11-05T16:19:51.447Z - info: model AdMaterial defined for table: admaterials
.
2018-11-05T16:19:51.455Z - info: model AdPeriod defined for table: adperiods.
2018-11-05T16:19:51.457Z - info: model AdSlot defined for table: adslots.
2018-11-05T16:19:51.460Z - info: model Article defined for table: articles.
2018-11-05T16:19:51.462Z - info: model Attachment defined for table: attachments
.
2018-11-05T16:19:51.463Z - info: model AuthUser defined for table: authusers.
2018-11-05T16:19:51.465Z - info: model Board defined for table: boards.
2018-11-05T16:19:51.467Z - info: model Category defined for table: categories.
2018-11-05T16:19:51.468Z - info: model LocalUser defined for table: localusers.
2018-11-05T16:19:51.470Z - info: model Navigation defined for table: navigations
.
2018-11-05T16:19:51.471Z - info: model Random defined for table: randoms.
2018-11-05T16:19:51.473Z - info: model Reply defined for table: replies.
2018-11-05T16:19:51.475Z - info: model Resource defined for table: resources.
2018-11-05T16:19:51.477Z - info: model Setting defined for table: settings.
2018-11-05T16:19:51.479Z - info: model Text defined for table: texts.
2018-11-05T16:19:51.480Z - info: model Topic defined for table: topics.
2018-11-05T16:19:51.483Z - info: model User defined for table: users.
2018-11-05T16:19:51.485Z - info: model Webpage defined for table: pages.
2018-11-05T16:19:51.486Z - info: model Wiki defined for table: wikis.
2018-11-05T16:19:51.488Z - info: model WikiPage defined for table: wikipages.
2018-11-05T16:19:51.489Z - info: db exports: ID_LENGTH, sequelize, nextId, sync,
 AdMaterial, AdPeriod, AdSlot, Article, Attachment, AuthUser, Board, Category, L
ocalUser, Navigation, Random, Reply, Resource, Setting, Text, Topic, User, Webpa
ge, Wiki, WikiPage
(node:36572) UnhandledPromiseRejectionWarning: SequelizeAccessDeniedError: ER_AC
CESS_DENIED_ERROR: Access denied for user 'root'@'localhost' (using password: YE
S)
    at Handshake._callback (D:\GitHub\itranswarp.js\www\node_modules\sequelize\l
ib\dialects\mysql\connection-manager.js:83:20)
    at Handshake.Sequence.end (D:\GitHub\itranswarp.js\www\node_modules\mysql\li
b\protocol\sequences\Sequence.js:86:24)
    at Handshake.ErrorPacket (D:\GitHub\itranswarp.js\www\node_modules\mysql\lib
\protocol\sequences\Handshake.js:105:8)
    at Protocol._parsePacket (D:\GitHub\itranswarp.js\www\node_modules\mysql\lib
\protocol\Protocol.js:280:23)
    at Parser.write (D:\GitHub\itranswarp.js\www\node_modules\mysql\lib\protocol
\Parser.js:75:12)
    at Protocol.write (D:\GitHub\itranswarp.js\www\node_modules\mysql\lib\protoc
ol\Protocol.js:39:16)
    at Socket.<anonymous> (D:\GitHub\itranswarp.js\www\node_modules\mysql\lib\Co
nnection.js:103:28)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at addChunk (_stream_readable.js:263:12)
    at readableAddChunk (_stream_readable.js:250:11)
    at Socket.Readable.push (_stream_readable.js:208:10)
    at TCP.onread (net.js:607:20)
(node:36572) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This
 error originated either by throwing inside of an async function without a catch
 block, or by rejecting a promise which was not handled with .catch(). (rejectio
n id: 1)
(node:36572) [DEP0018] DeprecationWarning: Unhandled promise rejections are depr
ecated. In the future, promise rejections that are not handled will terminate th
e Node.js process with a non-zero exit code.

求解?

ciey commented

运行了init-db.js之后把root的密码改掉了,why?

无法理解为啥又去读取config_default.js中的db.password,原以为是去读取config_development.js.

我是把config_default.js 里db:{password:'password' } 里的值修改为数据库root用户的密码就好了