Develop a Node.js script that connects to a MySQL database, retrieves all records from a "products" table, and calculates the total price of all products based on their quantity and unit price.
PLAINFORMAT
// Import the required modules
const mysql = require('mysql');

// Configure the MySQL connection
const connection = mysql.createConnection({
  host: 'localhost',
  user: 'your_username',
  password: 'your_password',
  database: 'your_database'
});

// Connect to the MySQL server
connection.connect((err) => {
  if (err) throw err;
  console.log('Connected to the MySQL server.');

  // Query the products table
  const query = 'SELECT * FROM products';
  connection.query(query, (err, results) => {
    if (err) throw err;

    // Calculate the total price of all products
    let totalPrice = 0;
    results.forEach((product) => {
      totalPrice += product.quantity * product.unit_price;
    });

    // Log the total price
    console.log(`Total price of all products: ${totalPrice}`);

    // Close the connection
    connection.end();
  });
});