我收到提示: 錯誤:錯誤:握手閒置超時到的NodeJS MySQL連接錯誤
0
A
回答
0
使用連接池:
var mysql = require('mysql');
var pool = mysql.createPool({
host : 'example.org',
user : 'bob',
password : 'secret'
});
pool.getConnection(function(err, connection) {
// Use the connection
connection.query('SELECT something FROM sometable', function(err, rows) {
// And done with the connection.
connection.release();
// Don't use the connection here, it has been returned to the pool.
});
});
0
您可以使用node-mysql,它非常容易使用。我已經使用過一次,這裏是例子: -
var mysql = require('mysql');
var connection = mysql.createConnection({
host : 'localhost',
user : 'me',
password : 'secret',
database : 'my_db'
});
connection.connect();
connection.query('SELECT 1 + 1 AS solution', function(err, rows, fields) {
if (err) throw err;
console.log('The solution is: ', rows[0].solution);
});
connection.end();
相關問題
- 1. nodejs連接mysql錯誤
- 2. mysql連接丟失錯誤nodejs
- 3. 將nodejs連接到mysql
- 4. MySQL連接錯誤
- 5. MySQL連接錯誤
- 6. MySQL錯誤連接到MySQL失敗
- 7. Mysql連接錯誤
- 8. 錯誤MySQL連接
- 9. 連接mysql錯誤
- 10. 連接錯誤MySQL
- 11. C++連接到mysql與庫的錯誤
- 12. 連接mysql得到廢棄的錯誤
- 13. php mysql - 連接到locahost的錯誤
- 14. 連接到MySQL的錯誤Zend Framework
- 15. 用的NodeJS MSSQL連接超時錯誤
- 16. NodeJS中的MySQL錯誤:無法以root身份連接
- 17. Java的MySQL連接錯誤
- 18. Android的Mysql連接錯誤
- 19. Python的 - MySQL連接錯誤
- 20. 無法將nodejs連接到mysql
- 21. mysql C++連接器連接錯誤
- 22. 錯誤,同時連接到MySQL
- 23. 連接錯誤:Excel VBA到遠程MySQL
- 24. Jython連接到Mysql數據庫錯誤
- 25. 使用PHP連接到MySQL:錯誤?
- 26. Tomcat7 MySQL連接錯誤
- 27. 與MySQL連接錯誤
- 28. Hive mysql連接器錯誤
- 29. php&mySQL連接錯誤
- 30. MySQL錯誤「連接太多」
您可以發佈在上下文中的代碼的NodeJS? – 2016-04-28 06:20:46
看到這個帖子:http://stackoverflow.com/questions/20210522/nodejs-mysql-error-connection-lost-the-server-closed-the-connection – Subburaj
變化'主持人: 「127.0.0.1」''到主機:「localhost」的' –