Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Database connection failed: Error: ER_BAD_DB_ERROR: Unknown database 'database-1'

I created a MYSQL database in AWS RDS, and this is the config settings setup:

DB instance ID
database-1
Engine version
8.0.28
DB name
-

so as you can see, there isn't a db name. So now, when I go to create a table via my code, or even mysql workbench, since no db name is included, it fails with:

Database connection failed: Error: ER_BAD_DB_ERROR: Unknown database 'database-1'

I am trying this in code as well:

var mysqlconn = mysql.createConnection({
    host: 'database-1.xxx.com,
    user: 'username',
    password: 'pw,
    port: '3306',
    database: 'database-1'
});

let createTable = "CREATE TABLE table_name (name VARCHAR(256),email VARCHAR(256),number INT(32))"

but it gives the above error. any advice / help is much appreciated

like image 309
devdude19289 Avatar asked Mar 08 '26 22:03

devdude19289


1 Answers

When creating the RDS instance you have the option to have RDS create an initial database. If you do not provide a value, RDS does not create a database at all (see image below). You'll need to connect to the instance and issue the command create a database yourself, e.g.

CREATE DATABASE mydb;

RDS MySQL Additional configuration screen

like image 114
Ben Whaley Avatar answered Mar 10 '26 11:03

Ben Whaley