1

I'm trying to get a node.js app that uses mysql to work. I run sudo node app.js and I get this error:

Express server listening on port 80 in development mode

events.js:48
        throw arguments[1]; // Unhandled 'error' event
                       ^
Error: Access denied for user 'root'@'localhost' (using password: YES)
    at cmd.process_packet (/Users/.../Documents/Code/.../node_modules/mysql-native/lib/mysql-native/command.js:35:15)
    at SocketClient.dispatch_packet (/Users/.../Documents/Code/.../node_modules/mysql-native/lib/mysql-native/socketclient.js:105:32)
    at Socket.<anonymous> (/Users/.../Documents/Code/.../node_modules/mysql-native/lib/mysql-native/socketclient.js:59:18)
    at Socket.emit (events.js:67:17)
    at TCP.onread (net.js:362:31)

I set up a secure user and password for mysql but it's not asking me for a password besides one for sudo. I'm a beginner with both node.js and especially mysql so any help would be appreciated.

5
  • Did you application come with a config file that you had to edit to give it permissions? Are you running the application as root? Commented May 4, 2012 at 1:28
  • Where would I find the config file? I'm not sure what root would be, sorry. Commented May 4, 2012 at 1:56
  • Presumably you had to configure something to tell the application which server and port or socket to use to connect to MySQL; that configuration would also include a username and password. root is the superuser account, with uid 0. Are you running as root when you start the application? Commented May 4, 2012 at 2:00
  • In the client.js file, it says the user is root and the password is null so I think yes. Commented May 4, 2012 at 2:07
  • Once the system software allows you to do so, would you add that as an answer for the future? Thanks! Commented May 4, 2012 at 3:12

1 Answer 1

1

So I contacted someone who had done this before and he helped me through it. Basically I connected to mysql with mysql -u root -p, entered in my password, created the database and put use that database and entered in all the database information. Then in api.js under db.auth, in parenthesis I put the database name, my username and the password, each as strings separated by commas. In a separate terminal tab I then ran the node.js application and it worked.

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.