Not able to connect to mysql using TypeORM

Viewed 623

I have my nodejs setup using expressjs and typeorm (v. 0.2.25). My node js version is 12.18.0

I am using Mac OS to debug my application.

Below is the problem i faced: (Note: There is no problem compiling in windows.)

QueryFailedError: Connection lost: The server closed the connection.
....
 fatal: true,
  code: 'PROTOCOL_CONNECTION_LOST',
  query: "SELECT * FROM `INFORMATION_SCHEMA`.`TABLES` WHERE ....

I am using

await createConnection(); 

from typeorm and my typeorm.config is properly setup as follow

 "type": "mysql",
   "host": "localhost",
   "port": 3306,
   "username": "root",
   "password": "root",
   "database": "myDB",
   "synchronize": true,
   "logging": false,
   "entities": entities,
    ...

To take note that if the "synchronize" is set to false there is no problem debugging, the error only comes out if I set it to true.

Any one face this problem using typeorm? Search around but never get a proper answer. Any one had this experience b4 please help.

Thanks.

0 Answers
Related