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 回答
0
已接受的回答

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
专家
已回答 1 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则