You can execute MySQL queries from your Node.js application. For example, MySQL uses following statement to create simple table in database
Example SQL Query:-
Now try to create the same table through a Node.js application. Let’s create a create_mysql_table.js file
vim create_mysql_table.js
Add the following content. Update the MySQL details according to your setup. Also, make sure that database already exists on MySQL server.
Execute the file using node command. If everything goes fine, you will see results like below.
node create_mysql_table.js Output: Database connected successfully! Table created successfully