dbConfig.js 519 B

123456789101112131415161718192021222324
  1. // dbConfig.js
  2. const mysql = require('mysql');
  3. const connection = mysql.createConnection({
  4. host: 'localhost',
  5. user: 'root',
  6. password: '',
  7. database: 'community_rule',
  8. });
  9. // const mysql = require('mysql2');
  10. // const connection = mysql.createConnection({
  11. // host: 'localhost',
  12. // user: 'root',
  13. // password: 'your_mysql_password',
  14. // database: 'your_database_name',
  15. // });
  16. connection.connect((err) => {
  17. if (err) throw err;
  18. console.log('Connected to the database');
  19. });
  20. module.exports = connection;