我想在mysql中创建数据库我在Windows 8中安装了MySQL 5.6,在安装过程中,安装程序从不问我用户名或密码。当我执行命令" router.use(function(req, res, next){
if(req.user){
res.locals.username = req.user.username
}else{
res.redirect('/login');
}
next();
});
router.get('/', function(req, res, next) {
res.render('dashboard');
});
"它给了我以下错误:
ERROR 1044(42000):拒绝用户访问'' localhost'数据库' ivs'我现在该怎么办?
答案 0 :(得分:3)
您使用的是默认用户,而不是 root 。默认用户剂量有足够的权限创建数据库。使用root用户启动客户端
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var participantSchema= new Schema({
createdAt: { type: Date, default: Date.now },
});
var Participant = mongoose.model('Participant', participantSchema, 'participants');
module.exports = Participant;
答案 1 :(得分:0)
经过与@Bernd Buffen的讨论,我得到了解决问题的方法,当我使用'创建数据库ivs'我实际上没有使用&root;' root'用户(我已经使用来宾用户登录)所以要将其更改为root我使用以下命令:
C:\ Program Files(x86)\ MySQL \ MySQL Server 5.6 \ bin> mysql -uroot 然后我用
mysql> create database ivs; to create database named 'ivs'