Store data from online form in sql database

0

I am trying to save data from a form in a sql database. The form is written in html / js, running locally on an express server. The sql database is on aws.

I create a connection to the db like this:

var connection = mysql.createConnection({ 
     host: 'endpoint from connectivity tab', 
     port: '3306', 
     user: 'admin', 
     password: 'master pw' 

When I submit the form, though, a red error on the top of the browser displays Error: ER_NO_DB_ERROR: No database selected. When I add the database identifier name from RDS > Databases > database identifier such as

var connection = mysql.createConnection({ 
     host: 'endpoint from connectivity tab', 
     port: '3306', 
     user: 'admin', 
     password: 'master pw', 
     database: 'database identifier' 

and then run npm start, though, I receive an error in my terminal that says errno: 1049 sqlMessage: "Unknown database 'database identifier' " obviously with my identifier as the actual name. My db is publically accessible.

Also, on VPC I created an Inbound Rule which allows all connections from anywhere to the db.

Am I going about saving data to a sql db in the right way?

1 Antwort
0
Akzeptierte Antwort

Hi,

The database field must contain the database name (DB name on the instance configuration screen) instead of the identifier.

However, this field could be empty, since AWS will not have created the database if you did not specify it during creation, and you will need to connect to the RDS MySQL instance and run the CREATE DATABASE DB_NAME command.

Take a look at the following link in case it is.

profile picture
EXPERTE
beantwortet vor einem Jahr

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen