Connect to MySQL with Node in GoormIDE

Connect to MySQL with Node in GoormIDE

DevSprout

5 лет назад

11,027 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@nancytran1627
@nancytran1627 - 28.04.2019 19:42

Right when I enter sudo service mysql start, it shows "unrecognized service". Please help!

Ответить
@amzadvisers4204
@amzadvisers4204 - 20.06.2019 19:23

Changing user to root and typing out the password string is letting me run my app without errors. When I try to export to a variable like you showed I'm getting:

Error: ER_ACCESS_DENIED_ERROR: Access denied for user 'root'@'localhost' (using password: YES)


any ideas?

Ответить
@naijaguy1836
@naijaguy1836 - 02.07.2019 16:32

Hi I am also getting "unregonized service" i have tried reinstall mysql but get 2 warnings "No9 description " and "No Repository field" is that normal?

Ответить
@khanterh7995
@khanterh7995 - 15.07.2019 16:35

Hi, I tried sudo service mysql start and get mysql: unrecognized service. Reinstalled Mysql and followed all instructions, still same

Ответить
@morningfocus
@morningfocus - 06.08.2019 12:45

Tried running node main.js on goorm and I keep getting the error

Error: ER_ACCESS_DENIED_ERROR: Access denied for user 'root'@'localhost' (using password: YES)
and strings of texts beneath it.


I've taken all the steps of export MYSQL_PW=password

I'm not sure whether if my database is selected correctly or not...

Help please..

Ответить
@georgenastase3508
@georgenastase3508 - 16.08.2019 15:31

Hello, i have two containers, one is with mysql and one with node. It is a bit confusing because i see in your video
that you have all in one place (mysql and node). I followed the early instruction to install node in a new container, and now i have
two. How do i get all in one place like you have in your video?
Thanks

Ответить
@emmalawton4428
@emmalawton4428 - 24.08.2019 13:49

When I run 'node app.js' it throws an Error: cannot find module 'mysql'. I've created a brand new container following your previous video on how to create MySQL on Goormide, and have now just added the ig_clone database (saved in a file as ig_clone.sql) as well as the app.js file. Please can you help with why it's throwing this error?!

Ответить
@jasjones82
@jasjones82 - 28.08.2019 05:05

Hey Ian, thank you so much for sharing this video! Quick question - how can I remove my password from mysql?

Ответить
@abhishekshukla905
@abhishekshukla905 - 03.09.2019 18:21

Hey Ian!
I followed all the instructions but when i run node app.js it does not do anything and goes to next line , like no error nothing similar to when we enter password , i have used a demo which is like this-


CREATE DATABASE demo;
USE demo;

CREATE TABLE demo(
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(200)
);

INSERT INTO TABLES(name)
VALUES("abhi"),("rakesh"),("mahesh"),("abhishek");


SELECT COUNT(*) FROM demo;




and have as far as i know have linked it correctly on my node app.js file here is the code-


var mysql=require("mysql");

var connection = mysql.createConnection(
{
host: "localhost",
user: "root",
password: process.env.MYSQL_PW,
database: "demo"

}
);


Here is the result i get on terminal-


root@goorm:/workspace/node_and_mysql# export MYSQL_PW=password
root@goorm:/workspace/node_and_mysql# sudo service mysql start
* Starting MySQL database server mysqld
...done.
root@goorm:/workspace/node_and_mysql# node app.js
root@goorm:/workspace/node_and_mysql#









So can you please just help me out with this , im unable to find what step am i doing wrong!
Once again thanks a lot sir you have helped us a lot! Have a great day!

Ответить
@raiobg
@raiobg - 15.10.2019 08:51

Hi Ian,



I did activate the password and apparently I forgot the password and now I deinstalled, deleted and reinstall the terminal but im still getting asked to give a password. How can I make it so I can start from scratch without being asked to give a password when giving mysql-ctl cli command?


Thanks !

Ответить
@hirofumimaeda985
@hirofumimaeda985 - 20.10.2019 13:48

Thank you for uploading the video. I tried to run it but get error as follows:

Error: getaddrinfo ENOTFOUND loyalhost loyalhost:3306
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:56:26)
--------------------
at Protocol._enqueue (/workspace/node_and_mysql2/node_modules/mysql/lib/protocol/Protocol.js:144:48)
at Protocol.handshake (/workspace/node_and_mysql2/node_modules/mysql/lib/protocol/Protocol.js:51:23)
at Connection.connect (/workspace/node_and_mysql2/node_modules/mysql/lib/Connection.js:119:18)
at Connection._implyConnect (/workspace/node_and_mysql2/node_modules/mysql/lib/Connection.js:457:10)
at Connection.query (/workspace/node_and_mysql2/node_modules/mysql/lib/Connection.js:199:8)
at Object.<anonymous> (/workspace/node_and_mysql2/app.js:20:12)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)

Would you tell me how to solve this problem?
(for your information, I already npm package.)

Ответить
@rachnatyaji3906
@rachnatyaji3906 - 23.11.2019 13:32

Hello,


I'm getting an error message

GoormIDE:
//setup connection
var mysql = require('mysql');

var connection = mysql.createConnection
({
host : 'localhost',
user : 'root',
database : 'join_us'
});

//test query
connection.query('SELECT 1 + 1 AS solution', function (error, results, fields) {
if (error) throw error;
console.log('The solution is: ', results[0].solution);
});

Error message:
root@goorm:/workspace/mySQL# node app.js
/workspace/mySQL/app.js:11
if (error) throw error;
^
Error: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client
at Handshake.Sequence._packetToError (/workspace/mySQL/node_modules/mysql/lib/protocol/sequences/Sequence.js:47:14)
at Handshake.ErrorPacket (/workspace/mySQL/node_modules/mysql/lib/protocol/sequences/Handshake.js:123:18)
at Protocol._parsePacket (/workspace/mySQL/node_modules/mysql/lib/protocol/Protocol.js:291:23)
at Parser._parsePacket (/workspace/mySQL/node_modules/mysql/lib/protocol/Parser.js:433:10)
at Parser.write (/workspace/mySQL/node_modules/mysql/lib/protocol/Parser.js:43:10)
at Protocol.write (/workspace/mySQL/node_modules/mysql/lib/protocol/Protocol.js:38:16)
at Socket.<anonymous> (/workspace/mySQL/node_modules/mysql/lib/Connection.js:91:28)
at Socket.<anonymous> (/workspace/mySQL/node_modules/mysql/lib/Connection.js:525:10)
at Socket.emit (events.js:198:13)
at addChunk (_stream_readable.js:288:12)
--------------------
at Protocol._enqueue (/workspace/mySQL/node_modules/mysql/lib/protocol/Protocol.js:144:48)
at Protocol.handshake (/workspace/mySQL/node_modules/mysql/lib/protocol/Protocol.js:51:23)
at Connection.connect (/workspace/mySQL/node_modules/mysql/lib/Connection.js:119:18)
at Connection._implyConnect (/workspace/mySQL/node_modules/mysql/lib/Connection.js:457:10)
at Connection.query (/workspace/mySQL/node_modules/mysql/lib/Connection.js:199:8)
at Object.<anonymous> (/workspace/mySQL/app.js:10:12)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)

Ответить
@biblioteca.antarctica
@biblioteca.antarctica - 07.01.2020 00:46

now with sequelize????

Ответить
@sarathkrishnan5456
@sarathkrishnan5456 - 19.04.2020 09:04

hey ian can you help me with this,




root@goorm:/workspace/project# node app.js
/workspace/project/app.js:15
if (error) throw error;
^


Error: ER_ACCESS_DENIED_ERROR: Access denied for user 'root'@'localhost' (using password: YES)
at Handshake.Sequence._packetToError (/workspace/project/node_modules/mysql/lib/protocol/sequences/Sequence.js:47:14)
at Handshake.ErrorPacket (/workspace/project/node_modules/mysql/lib/protocol/sequences/Handshake.js:123:18)
at Protocol._parsePacket (/workspace/project/node_modules/mysql/lib/protocol/Protocol.js:291:23)
at Parser._parsePacket (/workspace/project/node_modules/mysql/lib/protocol/Parser.js:433:10)
at Parser.write (/workspace/project/node_modules/mysql/lib/protocol/Parser.js:43:10)
at Protocol.write (/workspace/project/node_modules/mysql/lib/protocol/Protocol.js:38:16)
at Socket.<anonymous> (/workspace/project/node_modules/mysql/lib/Connection.js:88:28)
at Socket.<anonymous> (/workspace/project/node_modules/mysql/lib/Connection.js:526:10)
at Socket.emit (events.js:198:13)

Ответить
@AmanKumar-gq7li
@AmanKumar-gq7li - 23.04.2020 14:07

Just a reminder,go and install from npm MySQL.Otherwise it wont work. npm install MySQL in each project where you want to use MySQL.

Ответить
@leratomawela
@leratomawela - 06.07.2020 18:45

Hi Ian, I keep getting the following error after I execute node app.js ------- TypeError: mysql.createConnection is not a function?
What could I be doing wrong?

Ответить
@razibulhoque1416
@razibulhoque1416 - 27.08.2020 01:12

Hey I'm getting an error: ER_ACCESS_DENIED_ERROR: Access denied for user 'root'@'localhost' (using password:YES), how do I remedy this?

Ответить
@cristianmartin1099
@cristianmartin1099 - 07.09.2020 21:48

Nice,thanks Ian.

Ответить
@tabishshamim9030
@tabishshamim9030 - 06.11.2020 11:37

Hey ian please make a video on authentication using node js and mysql

Ответить
@MolonLabe300
@MolonLabe300 - 07.11.2020 11:34

var connection = mysql.createConnection({
ReferenceError: mysql is not defined

Done various things to resolve this including playing with names in package.JSON etc

Ответить
@bacs_aditisingri
@bacs_aditisingri - 17.05.2022 12:28

Thank you so much !

Ответить
@TazExprez
@TazExprez - 21.06.2022 21:50

Thanks a lot for this!

Ответить
@rohitsurvase4190
@rohitsurvase4190 - 13.08.2022 10:50

Hi,
Can we connect to groom MySQL db using remote connection from python

Ответить
@tolveasna3843
@tolveasna3843 - 26.10.2022 10:57

How do we connect Python and Mysql in goormide?

Ответить
@tolveasna3843
@tolveasna3843 - 26.10.2022 10:58

Thanks for sharing

Ответить