I'm trying to make a website by using node.js, mysql and sequelize with my friends, so I downloaded database files my friend made.
But I cannot create and recognize database table.
How can I fix this problem..?
I already tried " sequelize db:create " on the server terminal.
The error codes I got are
{ SequelizeConnectionError: Unknown database 'database_development'
at ...
name: 'SequelizeConnectionError',
parent:
{ Error: Unknown database 'database_development'
at ....
code: 'ER_BAD_DB_ERROR',
errno: 1049,
sqlState: '42000',
sqlMessage: 'Unknown database \'database_development\'' },
original:
{ Error: Unknown database 'database_development'
at .....
code: 'ER_BAD_DB_ERROR',
errno: 1049,
sqlState: '42000',
sqlMessage: 'Unknown database \'database_development\'' } }
use following command to create CREATE DATABASE IF NOT EXISTS <db_name>;
Related
I'm using Node.js and TypeORM with MySQL but the error shows MariaDB I don't know why. I'm trying to use array in User entity and this must be the error
ERROR:
QueryFailedError: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
code: 'ER_PARSE_ERROR',
errno: 1064,
sqlMessage: "You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version
for the right syntax to use near '' at line 1",
sqlState: '42000',
index: 0,
sql: 'ALTER TABLE `user` ADD `favorites` text NOT NULL DEFAULT '
},
code: 'ER_PARSE_ERROR',
errno: 1064,
sqlMessage: "You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1",
sqlState: '42000',
index: 0,
sql: 'ALTER TABLE `user` ADD `favorites` text NOT NULL DEFAULT '
}
The columns causing the error:
#Column({ type: "simple-array", default: [] })
favorites: string[];
#Column({ type: "simple-array", default: [] })
cart: string[];
You can't have default value for column type text in mysql. Remove the default parameter in the column options and the query should work.
If you still want to have any default value set, you can write a native mysql trigger or use typeorm #AfterInsert hook to set the value of columns cart or favorites just after they're inserted in the database.
When running php artisan migrate, It gives following error message:
Illuminate\Database\QueryException
SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo for http failed: No such host is known. (SQL: select * from information_schema.tables where table_schema = my_art_stock and table_name = migrations and table_type = 'BASE TABLE')
at C:\Users\installerjoe\laravel-projects\myArtStock-project\vendor\laravel\framework\src\Illuminate\Database\Connection.php:712
708▕ // If an exception occurs when attempting to run a query, we'll format the error
709▕ // message to include the bindings with SQL, which will make this exception a
710▕ // lot more helpful to the developer instead of just the database's errors.
711▕ catch (Exception $e) {
➜ 712▕ throw new QueryException(
713▕ $query, $this->prepareBindings($bindings), $e
714▕ );
715▕ }
716▕ }
1 C:\Users\installerjoe\laravel-projects\myArtStock-project\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70
PDOException::("PDO::__construct(): php_network_getaddresses: getaddrinfo for http failed: No such host is known. ")
2 C:\Users\installerjoe\laravel-projects\myArtStock-project\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70
PDO::__construct("mysql:host=http://art-stock-db.cujslgoio4sv.us-east-2.rds.amazonaws.com/;port=3306;dbname=my_art_stock", "stockadmin", "indianopen11*", [])
Please what causes this error, server configurations or laravel configuration? I'd really appreciate if someone offers a solution to this error.
I'm making an API and although all the syntax and the query fired is correct but it is showing me
code: 'ER_PARSE_ERROR',
errno: 1064,
sqlMessage: "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'load' at line 1",
sqlState: '42000',
index: 0,
sql: 'select * from load'
My code
Router.get("/",(req,res)=>{
mysqlConnection.query("select * from load",(err,rows,fields)=>{
if(!err){
res.send(rows);
}else{
console.log(err);
}
})
});
'load' is the table name in my MySQL database and I want to fetch everything from there.
LOAD is a reserved word in MySQL, as part of LOAD DATA or LOAD XML. If you want to use 'load' as a table name you'll have to quote it with backticks:
select * from `load`
I've created a directory name 'sp-node-mysql' and have a file called 'app.js' in it. My app.js file contains my connection code, and when I open the command prompt in my sp-node-mysql directory, I run the command 'mysql -u root -p' to establish a connection. Once connected, I try to use the database established in my app.js file. To do this, I type the command 'use articles', and then I get 'ERROR 1049 (42000): Unknown database 'articles''. Here's my app.js code:
var mysql = require("mysql");
// First you need to create a connection to the db
var connection = mysql.createConnection({
host: "localhost",
user: "root",
password: "password",
database: 'articles'
});
connection.connect();
var articles = {
}
The error is clearly stated:
Unknown database 'articles'
there is no database with the name articles on the connected server. Check what the exact name of the dataabase on the server and correct it in code and try again.
I am trying to connect to A DB on Redshift in r using following syntax (I am using a Mac):
odbcConnect("xxxxaddresss.redshift.amazonaws.com:5439", uid = "xxxx", pwd = "xxxx")
and get the following errors.
Warning messages:
1: In
RODBC::odbcDriverConnect("DSN=xxxxaddresss.redshift.amazonaws.com:5439;UID=xxxx;PWD=xxxx")
: [RODBC] ERROR: state IM012, code 0, message [unixODBC][Driver
Manager]DRIVER keyword syntax error
2: In
RODBC::odbcDriverConnect("DSN=xxxxaddresss.redshift.amazonaws.com:5439;UID=xxxx;PWD=xxxx")
:
ODBC connection failed
What is the reason of the problem?