Requirements for mysql database in node.js server [duplicate] - mysql

This question already has answers here:
MySQL with Node.js
(9 answers)
Closed 8 years ago.
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?

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.

Related

How to fix a broken MySQL installation?

Installing a PHP application that requires MySQL or MariaDB, I first installed MariaDB via 'apt install' from the MariaDB repos, but there were behaviours with the installation of the application that seemed to be caused by some kind of incompatibility. Calls to the DB were timing out, and although I could see it was creating the DB, it was impossible to set the application up in its setup routine.
So I used apt remove to get rid of MariaDB. I saw the application had a *.deb installer for all requirements (wish I'd seen this sooner!) and, after removing PHP and Nginx, I attempted to install it the normal way. Unfortunately, the MySQL portion of the installation failed with:
Automatic maintenance of MySQL Server daemon disabled.
Packaging maintainer scripts detected a case that it does not know how to handle and cannot continue configuring MySQL. Automatic management of your MySQL Installation has been disabled to allow other packaging tasks to complete. For more details, see /etc/mysql/FROZEN
Unfortunately, /etc/mysql/FROZEN is a symlink to a non-existent file explaining downgrading. I can't run the uninstaller of the overall package or repair the installation with sudo --fix-broken install because the installer requires a MySQL password I can't provide it.
How can I fix my borked MySQL installation? If I could just get to a place to have MySQL run properly, understanding what left-overs perhaps from the MariaDB installation that I need to delete manually before trying to repair it, that would be helpful. FYI, the version of MariaDB was 10.3, and the version of MySQL the application package was installing was 5.7.
Any suggestions appreciated.

Connect to node.js after installing MySQL

When I type var mysql=require('mysql');, I get an error that mysql module is not found.
In which folder of node.js should MySQL be placed? Should the entire MySQL folder be placed?
I'm not quite sure what mysql folder you are talking about but I would recommend just using npm for this and letting it handle the installation of the package.
Simply go into the folder of your project and install the MySQL Module using npm install mysql.
You can read more about using and installing the MySQL Module here.

Update/Install mysql-client to version 5.7 using yum

I was writing my own chef recipe to install only the mysql client version 5.7 and not the server. I was trying to do this using yum and had written my own chef recipe, but it by default adds the version 5.5 instead of 5.7 and I am not able to update only the client to 5.7 using yum so that I could write my own recipe on chef.
When I give the version field in my recipe, it throws an error.
As with all things in Chef, it only does what you tell it. If there isn't a MySQL 5.7 package available in your configured yum repos, the package resource will error. We offer a yum_repository resource if you want to configure a new package source with newer versions, or you could use an rpm_package resource to install a single package directly if you make one yourself.

sql.h not found in Linux

I'm trying to migrate a PostgreSQL db to MySQL using Workbench and I need the PostgreSQL drivers to make the connection.
I'm following this post for installing the drivers and I'm having some issues while runing the make command:
./psqlodbc.h:41:10: fatal error: 'sql.h' file not found
I've read here that I need to install unixodbc-dev but then I have to uninstall libiodbc2-dev which then make reports missing iodbcinst.h file!
Is there a package where both headers are present? How can I install sql.h manually in the system?
BTW: I'm using Linux Mint.

What is forcing my system to look for MySQL in "/opt/local/var/run/mysqld/mysqld.sock"

I have been trying to get a ruby on rails app going on my machine for a little while now for a project I need to work on for work. The issue is, my system must be setting the default location of MySQL somewhere because every time I start the rails webserver (webrick) and run localhost:3000, I get the following error.
"Can't connect to local MySQL server through socket '/opt/local/var/run/mysqld/mysqld.sock' (2)"
I have deleted the installed version of mysql and removed all folders. I reinstalled mysql using BREW. I now have a running mysql instance. The output of "which mysql" prints "/usr/local/bin/mysql" which is actually a sim link to "/usr/local/Cellar/mysql/5.5.14/bin/mysql".
Does anyone know what might be forcing my rails apps to look for mysql in "/opt/local/var/run/mysqld/mysqld.sock"
NOTE: I deleted my current my.cnf because it was messing up the brew version of mysql I currently have running, so I know that is has nothing to do with that.
/opt/local is the default location for MacPorts-installed packages. Chances are you installed rails and or MySQL via MacPorts. Try:
sudo /opt/local/bin/port installed
to see what is installed.