0
votes

la base de données locale ne fonctionne pas avec mongo localhost

J'essaye de faire fonctionner un localhost MongoDB DB, mais je ne comprends pas. J'utilise Mac.

Voici ce que j'écris dans le shell (zsh):

gaetan@MacBook-Pro-de-Gaetan ~ % sudo killall mongod
Password:
No matching processes were found
gaetan@MacBook-Pro-de-Gaetan ~ % sudo killall mongo 
No matching processes were found
gaetan@MacBook-Pro-de-Gaetan ~ % sudo killall mongodb
No matching processes were found
gaetan@MacBook-Pro-de-Gaetan ~ % 

J'obtiens cette erreur:

gaetan@MacBook-Pro-de-Gaetan ~ % mongod --port 27018
{"t":{"$date":"2020-09-07T12:18:16.133+02:00"},"s":"I",  "c":"CONTROL",  "id":23285,   "ctx":"main","msg":"Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'"}
{"t":{"$date":"2020-09-07T12:18:16.133+02:00"},"s":"W",  "c":"ASIO",     "id":22601,   "ctx":"main","msg":"No TransportLayer configured during NetworkInterface startup"}
{"t":{"$date":"2020-09-07T12:18:16.133+02:00"},"s":"I",  "c":"NETWORK",  "id":4648602, "ctx":"main","msg":"Implicit TCP FastOpen in use."}
{"t":{"$date":"2020-09-07T12:18:16.135+02:00"},"s":"W",  "c":"ASIO",     "id":22601,   "ctx":"main","msg":"No TransportLayer configured during NetworkInterface startup"}
{"t":{"$date":"2020-09-07T12:18:16.136+02:00"},"s":"I",  "c":"STORAGE",  "id":4615611, "ctx":"initandlisten","msg":"MongoDB starting","attr":{"pid":2944,"port":27018,"dbPath":"/data/db","architecture":"64-bit","host":"MacBook-Pro-de-Gaetan.local"}}
{"t":{"$date":"2020-09-07T12:18:16.136+02:00"},"s":"I",  "c":"CONTROL",  "id":23403,   "ctx":"initandlisten","msg":"Build Info","attr":{"buildInfo":{"version":"4.4.0","gitVersion":"563487e100c4215e2dce98d0af2a6a5a2d67c5cf","modules":["enterprise"],"allocator":"system","environment":{"distarch":"x86_64","target_arch":"x86_64"}}}}
{"t":{"$date":"2020-09-07T12:18:16.136+02:00"},"s":"I",  "c":"CONTROL",  "id":51765,   "ctx":"initandlisten","msg":"Operating System","attr":{"os":{"name":"Mac OS X","version":"19.6.0"}}}
{"t":{"$date":"2020-09-07T12:18:16.136+02:00"},"s":"I",  "c":"CONTROL",  "id":21951,   "ctx":"initandlisten","msg":"Options set by command line","attr":{"options":{"net":{"port":27018}}}}
{"t":{"$date":"2020-09-07T12:18:16.137+02:00"},"s":"E",  "c":"STORAGE",  "id":20557,   "ctx":"initandlisten","msg":"DBException in initAndListen, terminating","attr":{"error":"NonExistentPath: Data directory /data/db not found. Create the missing directory or specify another path using (1) the --dbpath command line option, or (2) by adding the 'storage.dbPath' option in the configuration file."}}
{"t":{"$date":"2020-09-07T12:18:16.137+02:00"},"s":"I",  "c":"NETWORK",  "id":20562,   "ctx":"initandlisten","msg":"Shutdown: going to close listening sockets"}
{"t":{"$date":"2020-09-07T12:18:16.137+02:00"},"s":"I",  "c":"-",        "id":20520,   "ctx":"initandlisten","msg":"Stopping further Flow Control ticket acquisitions."}
{"t":{"$date":"2020-09-07T12:18:16.137+02:00"},"s":"I",  "c":"CONTROL",  "id":20565,   "ctx":"initandlisten","msg":"Now exiting"}
{"t":{"$date":"2020-09-07T12:18:16.137+02:00"},"s":"I",  "c":"CONTROL",  "id":23138,   "ctx":"initandlisten","msg":"Shutting down","attr":{"exitCode":100}}

Aussi, quand j'écris ceci:

mongodb://localhost:27017/node-form
-: Connection error: connect ECONNREFUSED 127.0.0.1:27017 :-
(node:2930) UnhandledPromiseRejectionWarning: MongooseServerSelectionError: connect ECONNREFUSED 127.0.0.1:27017
    at new MongooseServerSelectionError (/Users/gaetan/WorkSpace/Back et front/Back/Fichiers_de_cours/node-forms_4/node_modules/mongoose/lib/error/serverSelection.js:24:11)
    at NativeConnection.Connection.openUri (/Users/gaetan/WorkSpace/Back et front/Back/Fichiers_de_cours/node-forms_4/node_modules/mongoose/lib/connection.js:823:32)
    at Mongoose.connect (/Users/gaetan/WorkSpace/Back et front/Back/Fichiers_de_cours/node-forms_4/node_modules/mongoose/lib/index.js:333:15)
    at Object.<anonymous> (/Users/gaetan/WorkSpace/Back et front/Back/Fichiers_de_cours/node-forms_4/start.js:8:10)
    at Module._compile (internal/modules/cjs/loader.js:1138:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
    at Module.load (internal/modules/cjs/loader.js:986:32)
    at Function.Module._load (internal/modules/cjs/loader.js:879:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47
(node:2930) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:2930) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

J'ai compris :

{"t":{"$date":"2020-09-07T12:01:27.943+02:00"},"s":"I",  "c":"CONTROL",  "id":23285,   "ctx":"main","msg":"Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'"}
{"t":{"$date":"2020-09-07T12:01:27.945+02:00"},"s":"W",  "c":"ASIO",     "id":22601,   "ctx":"main","msg":"No TransportLayer configured during NetworkInterface startup"}
{"t":{"$date":"2020-09-07T12:01:27.945+02:00"},"s":"I",  "c":"NETWORK",  "id":4648602, "ctx":"main","msg":"Implicit TCP FastOpen in use."}
{"t":{"$date":"2020-09-07T12:01:27.946+02:00"},"s":"W",  "c":"ASIO",     "id":22601,   "ctx":"main","msg":"No TransportLayer configured during NetworkInterface startup"}
{"t":{"$date":"2020-09-07T12:01:27.946+02:00"},"s":"I",  "c":"STORAGE",  "id":4615611, "ctx":"initandlisten","msg":"MongoDB starting","attr":{"pid":2652,"port":27017,"dbPath":"/data/db","architecture":"64-bit","host":"MBP-de-Gaetan"}}
{"t":{"$date":"2020-09-07T12:01:27.946+02:00"},"s":"I",  "c":"CONTROL",  "id":23403,   "ctx":"initandlisten","msg":"Build Info","attr":{"buildInfo":{"version":"4.4.0","gitVersion":"563487e100c4215e2dce98d0af2a6a5a2d67c5cf","modules":["enterprise"],"allocator":"system","environment":{"distarch":"x86_64","target_arch":"x86_64"}}}}
{"t":{"$date":"2020-09-07T12:01:27.946+02:00"},"s":"I",  "c":"CONTROL",  "id":51765,   "ctx":"initandlisten","msg":"Operating System","attr":{"os":{"name":"Mac OS X","version":"19.6.0"}}}
{"t":{"$date":"2020-09-07T12:01:27.946+02:00"},"s":"I",  "c":"CONTROL",  "id":21951,   "ctx":"initandlisten","msg":"Options set by command line","attr":{"options":{}}}
{"t":{"$date":"2020-09-07T12:01:27.947+02:00"},"s":"E",  "c":"NETWORK",  "id":23024,   "ctx":"initandlisten","msg":"Failed to unlink socket file","attr":{"path":"/tmp/mongodb-27017.sock","error":"Permission denied"}}
{"t":{"$date":"2020-09-07T12:01:27.947+02:00"},"s":"F",  "c":"-",        "id":23091,   "ctx":"initandlisten","msg":"Fatal assertion","attr":{"msgid":40486,"file":"src/mongo/transport/transport_layer_asio.cpp","line":919}}
{"t":{"$date":"2020-09-07T12:01:27.947+02:00"},"s":"F",  "c":"-",        "id":23092,   "ctx":"initandlisten","msg":"\n\n***aborting after fassert() failure\n\n"}

cela ne fonctionne pas non plus avec le nœud lorsque j'essaie de me connecter à la base de données locale. En fin de compte, je souhaite me connecter à une base de données locale via un nœud en utilisant 'Dotenv' et cette ligne de code: DATABASE = mongodb: // localhost: 27017 / node-form

mais j'obtiens encore une erreur:

mongod

ici avec un autre port:

MongoDB shell version v4.4.0
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused :
connect@src/mongo/shell/mongo.js:362:17
@(connect):2:6
exception: connect failed
exiting with code 1

De plus, il ne fonctionne nulle part:

mongo


3 commentaires

essayez un autre port


Le problème vient de: "Impossible de dissocier le fichier socket". Et puisque mongod ne fonctionne pas. Le service mongo ne peut pas démarrer et vous ne pouvez pas vous y connecter avec node.js. Peut-être que cela pourrait aider: stackoverflow.com/questions/29813648/...


Je n'ai pas travaillé non plus. De plus, je n'ai pas compris la moitié des choses qu'ils ont dites, je suis nouveau dans ce domaine.


3 Réponses :


-1
votes

Vous pourriez donner la solution ici un coup. SocketException: Adresse déjà utilisée MONGODB

Puisqu'il renvoie une erreur de socket, le port par défaut de mongodb pourrait être utilisé par un autre service même si cela est hautement improbable.


0 commentaires

0
votes

Essayez de créer un nouveau répertoire 'db' et 'log' dans le répertoire data sous le répertoire d'installation 'MongoDB' et un nouveau fichier 'mongo.log' sous le répertoire 'log'


0 commentaires

0
votes

Merci pour votre réponse. Mais je pense que quelque chose s'est mal passé avec l'installation. Il y a quelques semaines, j'ai formaté mon mac et tout réinstallé de manière propre en utilisant Brew. Maintenant, tout fonctionne bien. Merci quand même


0 commentaires