Mini Proyecto Backend NodeJS connects to a local MySQL database namedDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/brandonvergara1220-del/Mini-Proyecto-Backend-NodeJS/llms.txt
Use this file to discover all available pages before exploring further.
ejemploformulario. Before running the application for the first time, you must create the database, create the required table, and ensure that the credentials in conexion.js match your local MySQL installation. This page walks through every step from a fresh MySQL installation to a working database connection.
Prerequisites
- MySQL 5.7+, MariaDB 10.3+, or any compatible MySQL-protocol server installed and available on your machine.
- The
mysqlcommand-line client, MySQL Workbench, or another SQL client to execute the setup queries. - The project cloned and
npm installcompleted (see Environment Configuration).
Setup Steps
Start the MySQL Server
Make sure the MySQL service is running before attempting to connect.Linux (systemd):macOS (Homebrew):Windows (Command Prompt as Administrator):
ReplaceMySQL80with the actual service name shown in Windows Services if yours differs (e.g.MySQL57orMariaDB).
Create the Database
Log in to the MySQL shell and create the Once inside the MySQL prompt, run:The
ejemploformulario database:IF NOT EXISTS clause makes the statement safe to run more than once — it will not raise an error if the database already exists.Create the usuarios Table
While still connected to
You can verify the table was created correctly with:
ejemploformulario, create the usuarios table that the registration form writes to:| Column | Type | Description |
|---|---|---|
id | INT AUTO_INCREMENT | Unique identifier, generated automatically for each row |
nombre | VARCHAR(100) | First name submitted by the registration form |
apellido | VARCHAR(100) | Last name submitted by the registration form |
created_at | TIMESTAMP | Date and time the record was inserted, set automatically |
Update conexion.js with Your Credentials
Open If your MySQL
conexion.js and confirm (or update) the connection parameters to match your MySQL installation:conexion.js
root user has a password set, replace the empty string "" with that password. If you are using a dedicated application user (recommended — see the tip below), replace both user and password accordingly.Connection Parameters Reference
Themysql.createConnection() call in conexion.js accepts the following options used by this project:
| Parameter | Current Value | Description |
|---|---|---|
host | "localhost" | Hostname or IP address of the MySQL server. Use "localhost" or "127.0.0.1" for a local installation. |
database | "ejemploformulario" | The database to select automatically upon connecting. Must exist before the app starts. |
user | "root" | MySQL username used to authenticate. |
password | "" | Password for the specified user. An empty string means no password is set. |
The default configuration connects as
root with an empty password. This is only safe on a local development machine that is not accessible from the network. MySQL installations on Linux often require at least a socket-authenticated root session, which may mean you need to set a password or create a separate user even for local development.