我正在关注如何使用postgres + node guide。我已经到了创建表创建脚本的目的。
这是我在教程中使用的代码:
var pg = require('pg');
var connectionString = process.env.DATABASE_URL || 'postgres://postgres:postgres@localhost:5432/todo';
var client = new pg.Client(connectionString);
client.connect();
var query = client.query('CREATE TABLE items(id SERIAL PRIMARY KEY, text VARCHAR(40) not null, complete BOOLEAN)');
query.on('end', function() { client.end(); });
但是,当我执行node models/database.js
步骤时,收到以下错误:
ram@ram-windows-xp-ubuntu:~/Development/Web/Projects/node-postgres$ node models/database.js
events.js:85
throw er; // Unhandled 'error' event
^
error: password authentication failed for user "postgres"
at Connection.parseE (/home/ram/Development/Web/Projects/node-postgres/node_modules/pg/lib/connection.js:539:11)
at Connection.parseMessage (/home/ram/Development/Web/Projects/node-postgres/node_modules/pg/lib/connection.js:366:17)
at Socket.<anonymous> (/home/ram/Development/Web/Projects/node-postgres/node_modules/pg/lib/connection.js:105:22)
at Socket.emit (events.js:107:17)
at readableAddChunk (_stream_readable.js:163:16)
at Socket.Readable.push (_stream_readable.js:126:10)
at TCP.onread (net.js:538:20)
我是使用ubuntu的新手,我试图按照this guide中的步骤进行操作但很困惑。对不起,请打扰朋友,如果你能做到需要,我会感到谦卑。