12345678910111213141516171819 |
- import { createPool } from 'mysql2/promise';
- const pool = createPool({
- host: '127.0.0.1',
- user: 'root',
- password: 'Jing@123',
- database: 'shopping',
- waitForConnections: true,
- connectionLimit: 10,
- maxIdle: 10, // max idle connections, the default value is the same as `connectionLimit`
- idleTimeout: 60000, // idle connections timeout, in milliseconds, the default value 60000
- queueLimit: 0,
- });
- let [res] = await pool.query('select 1 as T;');
- console.log(res);
- export default pool;
|