3

I've found a lot of tutorials explaining how to install "node-mysql" (basically: "npm install mysql" and that's it) and others explaining how to make queries but nothing in-between.

I mean: with no GUI, how do you configure node-mysql (Mysql login, Mysql password, first table,..) before using it?

OR: How to install a GUI to access node-mysql for edition (which would solve problem 1)?

I tried "Mysql Workbench" via its wizard but I get a "Cannot connect to Database Server" while the host and the port are ok. I searched the "MySQL Workbench" website but there's nothing about node-mysql.

Node-Mysql seems to be the first choice when it comes to use mysql with node.js but, surprisingly, there's absolutely nothing about my issues, anywhere.

Thank you for your help.

Baylock
  • 1,246
  • 4
  • 25
  • 49

1 Answers1

0

you don't need to configure node-mysql itself, you need to learn how to add users to mysql database.

if you already have existing user, node-mysql client is very straightforward to use:

var client = mysql.createClient({
  user: 'someusername',
  password: 'somepassword',
});
Andrey Sidorov
  • 24,905
  • 4
  • 62
  • 75
  • Thank you very much Andrey. First of all, I don't have any existing user as I just installed node-mysql. Now, about your script: Where do I have to put it? Obviously I will not create a Mysql admin login, password each time I execute the node.js server file. And what about creating a database and a table and columns and types... In PHPMyAdmin (I have a php background), at the beginning of any project, I create all those things via a GUI. Doing otherwise may seem trivial but for me, it's a no man's land. Thank you for your help. – Baylock Apr 19 '12 at 01:41
  • Forgot to mention: tried your link which should be helpful but none of the shell commands related to mysql seem to work for me. i.e.:"mysql --user=root mysql" etc.. All I get is "command not found" (don't know if it helps but the only mysql folder I found on my Mac is there:"users/me/node_modules/mysql/") – Baylock Apr 19 '12 at 01:53
  • do you use local mysql server? – Andrey Sidorov Apr 19 '12 at 02:17
  • Yes. For testing purposes. FYI: I'm testing node.js as php/ajax are not ideal for instant messaging. I installed node.js, now.js, express.js with no issue so far. I tried to use mongoDB (successfully) but it doesn't fit my needs as I really need to make relations between tables (and I have some experience with mysql queries. Learning a completely different way to manage data, among the rest, would be overwhelming for me). I can imagine how basic it is but I'm just stuck. – Baylock Apr 19 '12 at 02:25
  • if you have local installation of mysql server then you most likely have command line client called `mysql`. Can you start it from command line? on mac it's usually a /usr/local/bin/mysql (homebrew and package from mysql.com default location) – Andrey Sidorov Apr 19 '12 at 09:16
  • Thanks Andrey. It seems, from what you say that installing node-mysql doesn't install mysql itself (didn't know that and lot of blogs assume that it does, according to their tutorials), so I did what you say: "brew install mysql". Now it's definitely there, exactly where you said it would be but when I launch it trough "mysql" or "/usr/local/bin/mysql " command, here's what I get: "ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)". I tried to reach this "/tmp" folder and there it is with a bunch of files and folders but nothing related to mysql... – Baylock Apr 19 '12 at 23:23
  • what is the output of `ps ax | grep mysqld` (do you have server started?) – Andrey Sidorov Apr 20 '12 at 02:52