简体   繁体   English

Azure Web App MySQL In App引发错误

[英]Azure Web App MySQL In App throws error

I was closely following this tutorial to enable MySQl into web app that contains NodeJS application. 我一直在密切关注本教程,以将MySQl启用到包含NodeJS应用程序的Web应用程序中。 But upon enabling the MySQl it throws below below error. 但是在启用MySQl后,它将抛出以下错误。

在此处输入图片说明

And also when performing the Kudu instructions I am getting access denied. 而且在执行Kudu 指令时,我也被拒绝访问。 even though I am putting the correct credentials found in the file MYSQLCONNSTR_localdb. 即使我将正确的凭据放在文件MYSQLCONNSTR_localdb中,也是如此。

Change localhost to 127.0.0.1 in config.inc.php 在config.inc.php中将localhost更改为127.0.0.1

$cfg['Servers'][$i]['host'] = '127.0.0.1'; $ cfg ['Servers'] [$ i] ['host'] ='127.0.0.1'; The reason for this is that pma tries to connect to the mysql.socket if you use localhost. 原因是如果使用localhost,pma会尝试连接到mysql.socket。 If you use 127.0.0.1 PMA makes a TCP connection which should work. 如果使用127.0.0.1,则PMA会建立TCP连接,该连接应该可以正常工作。

Check config.js file below and make necessary change, 检查下面的config.js文件并进行必要的更改,

// config.js
const config = {
 app: {
   port: 3000
 },
 db: {
   host: 'localhost',
   port: 27017,
   name: 'db'
 }
};

module.exports = config;

// db.js
const mongoose = require('mongoose');
const config = require('./config');

const { db: { host, port, name } } = config;
const connectionString = `mongodb://${host}:${port}/${name}`;
mongoose.connect(connectionString);

// app.js
const express = require('express');
const config = require('./config');

const app = express();
app.listen(config.app.port);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM