How to connect to remote phpMyAdmin server using NodeJS + ExpressJS - javascript

I'm setting up a GraphQL server however I need to connect to a remote phpMyAdmin server which my friend provided and i am getting the error:
Error: getaddrinfo ENOTFOUND 54.193.13.37/phpmyadmin 54.193.13.37/phpmyadmin:3306
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:56:26)
here is the code i use to connect
const mysql = require('mysql');
const db = mysql.createConnection({
host: "54.193.13.37/phpmyadmin",
user: "some_user",
password: "some_password",
database:"some_DB",
})
db.connect((err) => {
if (err) throw err;
console.log("Connected!");
});
I've tried removing "http://", adding port, also the IP address 54.193.13.37 is an IP address for his clan website. So, the only way i have access to the database is by 54.193.13.37/phpmyadmin and i dont have any access to any config files or whatsoever, it's just a remote database that he gave me.
Thanks to whoever can help!

just remove the phpmyadmin in the host. Try host: host: "54.193.13.37".
Phpmyadmin is a web interface, but you want to connect directly to the mysql server wich is normaly on Port 3306.

Related

How can i solve this error when i use mysql module?

I use the node module to connect my local database, then log this error message:
Client does not support authentication protocol requested by server; consider upgrading MySQL client
next is my configuration:
const mysql = require("mysql");
const db = mysql.createPool({
host: "127.0.0.1",
user: "root",
password: "root",
database: "my_db_01"
});
db.query('select 1', (err, results)=>{
if (err) return console.log(err.message);
console.log(results);
});
I can make sure the configuration is correct.
This looks like a frequent issue in the bug reports for the mysql module.
That module hasn't had a commit since 2020. It has 172 open issues. I would consider it abandoned.
Use a different database module. mysql2 seems to be popular.

Connection to Redis cache failing

I have a node app connecting to a redis cache hosted on azure but whenever I'm trying to connect to it, the connection fails with an error message
I have enabled secure connection through a port and configured my node app accordingly
// This is my client module
const Redis = require("ioredis");
var client = new Redis(
{
port: 6380,
tls: true,
host: process.env.REDIS_HOST,
password: process.env.REDIS_PASSWORD,
family:
db: 0
}
);
module.exports = client;
This is the error I encounter whenever I start my app:
[ioredis] Unhandled error event: Error: unable to get local issuer certificate
at TLSSocket.onConnectSecure (_tls_wrap.js:1317:34)
at TLSSocket.emit (events.js:209:13)
at TLSSocket._finishInit (_tls_wrap.js:792:8)
at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:606:12)
The API ran for a while without any problems but then started throwing this error. My colleague is not having a problem running the same service and I'm assuming this is my machines certificates or lack of causing the issue. Any solutions or suggestions?
The problem was with the company wifi network I was using. The firewall did not allow me to connect to the cache.

Cannot connect to mysql server programmatically

I am trying to connect to a mysql server with the mysql library. I used the following code:
const mysql = require('mysql');
const connection = mysql.createConnection({
host : 'mysql.panamath.org',
user : <username>,
password : <password>,
database : <database>
});
connection.connect(err => {
if (err) return console.log(err);
console.log("Success connecting to database");
});
When I visit mysql.panamath.org, I am redirected to here, where my credentials work fine. However, when I run this connection, I get this error:
Error: ER_ACCESS_DENIED_ERROR: Access denied for user <username>#'129-2-181-10.wireless.umd.edu' (using password: YES)
code: 'ER_ACCESS_DENIED_ERROR',
errno: 1045,
sqlMessage: "Access denied for user <username>#'129-2-181-10.wireless.umd.edu' (using password: YES)",
sqlState: '28000',
fatal: true
It seems to be connecting to '129-2-181-10.wireless.umd.edu'. Interestingly, when I deployed through heroku, it was the same error except it was trying to connect to 'ec2-3-89-96-69.compute-1.amazonaws.com'. I also tried to connect through the terminal:
$ mysql -h mysql.panamath.org -u <username> -p
Enter password:
ERROR 1045 (28000): Access denied for user ...
with the same result.
What's going on here? Why can I connect through the website but not in my code? Is there another module or function for connecting to phpMyAdmin sites, or is the phpMyAdmin site connected to the server somehow?
MySQL cares about where you are connecting from.
Probably username#the-server-hosting-phpmyadmin is allowed to connect while username#129-2-181-10.wireless.umd.edu is not.
Consult the database administrator.

Connect to XMPP server using xmpp.js in the browser

I'm trying to run a test using a local xmpp server in the browser.
import { client } from '#xmpp/client';
const xmpp = client({
service: 'xmpp://localhost:5222/',
username: 'user',
password: 'pass',
});
xmpp.start().catch(err => {
console.error('start failed', err);
});
But I get the following error:
No compatible connection method found.
From what I've read, the browser expects a websocket connection instead of an xmpp connection.
The xmpp.js documentation says that it supports websockets as well, but I'm not sure what I have to change in order to successfully connect. Do I have to add WS support to my XMPP server?
Most likely you would have to change your service URI - both protocol as well as port part. As per xmpp.js client documentation you should use:
service: 'ws://localhost:5280/xmpp-websocket',
Exact path may be xmpp-server dependent (i.e. xmpp-websocket may not be needed) - please check your server's documentation.

To connect create-react-app reactJs with mysql

I have problem in connecting my create-react-app with mysql using npm.
Its working in nodejs when i tried seperately without npm. But, When i trying to connect using npm install mysql, It throws me an error...
TypeError: http.IncomingMessage is undefined
./node_modules/express/lib/request.js
Here is my code:
var express = require('express');
var mysql = require('mysql');
var connection =mysql.createConnection({
host: 'localhost',
user: 'user',
password: '',
database: 'reactproject'
});
connection.connect(function(err){
if(!err) {
console.log("Database is connected ... nn");
} else {
console.log("Error connecting database ... nn");
}
});
This will not work from react-app, since react code will run from client side.
You should use my-sql connection in different app and run in different port and call as api connection.
Thanks.
Adding from an #ashik answer is correct, but if you still want to use MySQL and reactjs simultaneously, you can start by creating your own boilerplate, there you can use MySQL on the server side and create APi/web service without having to separate the APi server and client projects reactjs.

Categories