0

I've installed node.js on my pc and created a server. Now, I'm trying use mysql module but it never connects with the database. I think I did not installed enough requirements for it. I just installed the mysql module with the command:

npm install mysql

Please tell me what should I install now? Do I need mysql cluster installed? Or anything else?

0

1 Answer 1

2

To install the MySQL node.js driver:

If you run just npm install mysql, you need to be in the same directory that your run your server. I would advise to do it as in one of the following examples:

For global installation:

npm install -g mysql

For local installation:

1- Add it to your package.json in the dependencies:

"dependencies": {
    "mysql": "~2.3.2",
     ...

2- run npm install


Note that for connections to happen you will also need to be running the mysql server (which is node independent)

To install MySQL server:

There are a bunch of tutorials out there that explain this, and it is a bit dependent on operative system. Just go to google and search for how to install mysql server [Ubuntu|MacOSX|Windows]. But in a sentence: you have to go to http://www.mysql.com/downloads/ and install it.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks fmsf, for your answer But how can I create mysql server?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.