Recently used Node to write a gadget, you need to use the MySQL database, the most widely used is the mysql library. And then, now
ORMso fire, simply have the
ORMright, I will not just be learning about, so to find Sequelize.js the
Take a look at
Sequelizethe document, so easy, two minutes to get ~
SequelizeConnectionRefusedError: connect ECONNREFUSED 127.0.0.1:3306
What the hell, why is this error? I clearly set up
localhost, why did it become
As usual, Google has indeed found that many people have encountered this problem. There are probably several solutions:
1. Do you think you can run without installing MySQL? Go and install the database!
2. What is your database running? Hurry
/etc/init.d/mysqld startup and running
3, the port is wrong
4, you are not turned on
skip-networkingthis option? Remove it !
See here, I could react, because I do not relate to the remote database access, as long as the use of
Unix socketcommunication is enough, so he is enabled
skip-networkingto make MySQL not listening on the specified port.
First science about
Do not listen for TCP/IP connections at all. All interaction with mysqld must be made using named pipes or shared memory (on Windows) or Unix socket files (on Unix). This option is highly recommended for systems where only local clients are permitted.
The translation is:
Do not listen for
mysqldinteractions must use named pipes or shared memory (on Windows) or
Unix socketfile (on Unix). It is highly recommended to use this option for systems that only allow local clients.
However, for safety, I do not want to remove this choice, we are reluctantly forced to do
Because read documents,
mysqlthe library is connected you can use
socketPaththis property to specify
Unix 套接字文件, but
Sequelize.jsdid not find the relevant property.
Finally had hair issue, and soon there dalao said that I can use
mysqlproperty. Here is the code for the test to succeed:
Mom's, it's that simple...
Original article, reproduced please indicate the source in the form of a link: https://blog.ttionya.com/article-1709.html