简体   繁体   中英

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

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, eg

CREATE DATABASE mydb;

RDS MySQL 附加配置屏幕

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM