Javascript 如何使用Node.js连接到远程mysql数据库
我正在尝试使用node连接到mysql数据库。当连接localhost时,它工作得非常好Javascript 如何使用Node.js连接到远程mysql数据库,javascript,mysql,node.js,Javascript,Mysql,Node.js,我正在尝试使用node连接到mysql数据库。当连接localhost时,它工作得非常好 var pool = mysql.createPool({ connectionLimit : 100, host : 'http://<ip-address here>/phpmyadmin', user : '*********', password : '*********', database : '*********' });
var pool = mysql.createPool({
connectionLimit : 100,
host : 'http://<ip-address here>/phpmyadmin',
user : '*********',
password : '*********',
database : '*********'
});
pool.getConnection(function(err, connection) {
// Use the connection
connection.query( 'SELECT * FROM table', function(err, rows) {
// And done with the connection.
connection.release();
// Don't use the connection here, it has been returned to the pool.
});
});
var pool=mysql.createPool({
连接限制:100,
主持人:'http:///phpmyadmin',
用户:'*********',
密码:'*********',
数据库:'***********'
});
pool.getConnection(函数(err,connection){
//使用连接
connection.query('SELECT*FROM table',函数(err,rows){
//连接完成了。
连接。释放();
//不要在此处使用连接,它已返回到池中。
});
});
上述代码不起作用。
我在Google和这里都没有找到任何答案。主机只包含IP地址,请尝试删除phpmyadmin