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
전문가
답변함 일 년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인