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?