strongloop mysql_node.js - Strongloop mysql connector ER_NO_DB_ERROR: No database selected

王棋
2023-12-01

I made a website with nodejs and strongloop. I used the mysql connector and tested the connection in Strongloop Arc. The connection is OK. I created the models with the arc tool (discover models). It was also OK.

But when I open the Strongloop API Explorer and do the test to get the data I Always get the error:

"ER_NO_DB_ERROR: No database selected".

mysql

node.js

strongloop

edited Oct 7 '15 at 11:55

Andrea 4,113 14 34 43 asked Oct 7 '15 at 11:17

Rik Dessers 1      can you

the content of

datasources.json? –

Vishal Kumar Oct 7 '15 at 11:32      { "db": { "name": "db", "connector": "mysql" }, "dbAuction": { "host": "localhost", "port": 3306, "database": "auctions", "password": "", "name": "dbAuction", "connector": "mysql", "user": "root" } } –

Rik Dessers Oct 7 '15 at 15:09      I'm using the dbAuction –

Rik Dessers Oct 7 '15 at 15:15      have you check if

dbAuction database has been created with required tables? –

Vishal Kumar Oct 8 '15 at 9:25

|

3 Answers

3

Have you confirmed that your model was connected to dbAuction instead of db? When using arc to add a model, the 'datasource' should be 'dbAuction'.

You can also check the model-config.json in 'server/' directory. A property named 'dataSource' belongs to the model name like

"modelname" : {

"dataSouce":"dbAuction"

...

},

...

answered Oct 8 '15 at 9:42

Zealseeker 183 9

|

This is the model-config.jsonse and return the data with respective to the parameter we send. Actually nodejs and strongloop is new to me, this is first time am working with them. I have followed their docs and created a table in mysql my running a file like below I ha

{

"_meta": {

"sources": [

"loopback/common/models",

"loopback/server/models",

"../common/models",

"./models"

],

"mixins": [

"loopback/common/mixins",

"loopback/server/mixins",

"../common/mixins",

"./mixins"

]

},

"User": {

"dataSource": "db"

},

"AccessToken": {

"dataSource": "db",

"public": false

},

"ACL": {

"dataSource": "db",

"public": false

},

"RoleMapping": {

"dataSource": "db",

"public": false

},

"Role": {

"dataSource": "db",

"public": false

},

"newModel": {

"dataSource": "db",

"public": true

},

"Biedingen": {

"dataSource": "dbAuction",

"public": true

},

"Kavel": {

"dataSource": "dbAuction",

"public": true

},

"Gebruikers": {

"dataSource": "dbAuction",

"public": true

},

"Message": {

"dataSource": "dbAuction",

"public": true

},

"Veilingen": {

"dataSource": "dbAuction",

"public": true

},

"Sourcemessage": {

"dataSource": "dbAuction",

"public": true

},

"Veilingenkavels": {

"dataSource": "dbAuction",

"public": true

},

"Veilingsoorten": {

"dataSource": "dbAuction",

"public": true

}

and the datasources.json

{

"db": {

"name": "db",

"connector": "mysql"

},

"dbAuction": {

"host": "localhost",

"port": 3306,

"database": "auctions",

"password": "",

"name": "dbAuction",

"connector": "mysql",

"user": "root"

}

}

answered Oct 8 '15 at 21:15

Rik Dessers 1

|

I can't since my reputation is too low.. I suggest you can change the 'mysql' in

"db": {

"name": "db",

"connector": "**mysql**"

into "memory" as it was initiated because the "db" is useful for some models while you changed wrongly so that 'db' cannot work well, which may lead to this problem.

answered Oct 10 '15 at 6:40

Zealseeker 183 9

|

ordpress database. The existing MYSQL db has two table names 'wp_post' and 'wp_postmeta' wp_post table | wp_postmeta |------------------------|-----------------| ID | meta_id |------------------

 类似资料:

相关阅读

相关文章

相关问答