index.js 502 B

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