can't access to database in mySql workbench? - mysql

when i try to access workbench database i get this error
SocketException: Connection refused (OS Error: Connection refused, errno = 111), address = localhost, port = 60500
this is code
Future connectToDb() async {
// var rng = Random();
final conn = await MySqlConnection.connect(ConnectionSettings(
host: 'localhost',
port: 3306,
user: 'root',
db: 'sql_workbench',
password: '12345678a#',
),
).then((value) {
print("value");
});
}

Related

I am getting error Flutter mysql1 package socket has been closed

Future<MySqlConnection> dbConnectSystem() async {
final conn = await MySqlConnection.connect(ConnectionSettings(
host: 'my_ip_adress',
port: 3306,
user: 'my_user_name',
password: 'my_password',
db: 'my_db'));
return conn;
}
I rented a hosting via natro and I'm trying to add and remove my data.

Error connecting nodejs app to heroku clear DB

I have a nodeJS + mysql app that works fine on local, but when I try to connect it to an Heroku clear DB database I'm getting error. Database credentials are ok because I'm using them same on another web app.
This is my connection code:
var mysql = require('mysql2');
var cnx = mysql.createConnection({
host: 'us-cdbr-east-xx.cleardb.com',
user: 'bb69add9159975',
password: 'fb0xxxxx',
database: 'heroku_65f44b5a5fxxxx',
multipleStatements: true
});
cnx.connect(err => {
if(!err){
console.log(`Database connection successful`);
}else{
console.log(`Databse connection failed: ${err}`);
}
});
module.exports = cnx;
This is the error on console:
Databse connection failed: Error: Access denied for user 'bb69add9159975'#'ip-10-0-125-110.ec2.internal' (using password: YES)
Thanks.

Error in connecting to Mysql from nodejs

I have started node-js recently and i was trying to connect my nodejs server with mysql.
The problem is i am getting an error, i really don't know why, i am using phpmyadmin.
Phpmyadmin details
user: root
host: localhost
password is not set
This is the image of my phpmyadmin database
This is the settings of my phpmyadmin console
This is the terminal where it is showing error connecting to DB
index.js
var express = require("express");
var app = express();
var mysql = require('mysql');
var port = process.env.PORT || 3000;
var connection = mysql.createConnection({
host: "localhost",
user: "root",
database: "learning",
});
connection.connect(function(err){
if(err) {
console.log('Error connecting to Db');
return;
}
console.log('Connection established');
console.log('3');
connection.end(function(err) {
console.log('Connection closed');
console.log('4');
process.exit();
});
});
app.listen(port,function(err1){
console.log("Listening on the port 3000");
});
connection to mysql from node js, you are use to mysql from node js connection
/config
/database.js
/server.js
/.env
const http = require('http');
const app = require('express')();
require('./config/database.js');
const bodyParser = require('body-parser');
const server = http.createServer(app);
server.listen(process.env.ServerPort, '0.0.0.0', () => {
logger.info(`Express server listening on port ${process.env.ServerPort}`);
});
When you run this:
node server.js
database.js file
const My = require('jm-ez-mysql');
// Init DB Connection
const connection = My.init({
host: process.env.DBHOST,
user: process.env.DBUSER,
password: process.env.DBPASSWORD,
database: process.env.DATABASE,
dateStrings: true,
charset: 'utf8mb4',
timezone: 'utc',
multipleStatements: true,
connectTimeout: 100 * 60 * 1000,
acquireTimeout: 100 * 60 * 1000,
timeout: 100 * 60 * 1000,
});
module.exports = {
connection,
};
I had changed the port from default 3306 of phpmyadmin mysql to 3308
therefore i added port: 3308 and it started working.
var connection = mysql.createConnection({
host: "localhost",
user: "root",
database: "learning",
port: 3308
});

bug with angular2-meteor app :failed connection to mysql via meteor

i'm trying to connect to mysql database with meteor using nodets:mysql and i'm facing this error :
Unhandled rejection Error: No infromation can be fetched by your database, please check your permissions
this is my part of code :
Meteor.startup(function() {
//Start of changes
var connectionSettings = {
host: '127.0.0.1',
user: 'root',
password: '',
database: 'test'
};
var db = Mysql.connect(connectionSettings);
})
i need to add the port of mysql
Meteor.startup(function() {
//Start of changes
var connectionSettings = {
host: '127.0.0.1',
port : (mysqlport),
user: 'root',
password: '',
database: 'test'
};
var db = Mysql.connect(connectionSettings);
})

node.js can't connect to mysql DB

I use CentOS on my server and node.js throws error
CONNECTION error: { [Error: ER_ACCESS_DENIED_ERROR: Access denied for user 'root'#'localhost' (using password: YES)]
code: 'ER_ACCESS_DENIED_ERROR',
errno: 1045,
sqlState: '28000',
fatal: true }
my local version on Ubuntu doesn't throw this error and php can connect to this DB with same credentials.
I use this code to connect to DB
var connect_params = require('./connect');
var express = require('express'),
app = express(),
mysql = require('mysql'),
connectionpool = mysql.createPool(connect_params.connection);
and my connect.js
var connection = {
host: 'localhost',
user: 'user',
password: 'password',
database: 'mydb'
};
exports.connection = connection;
Specifying the portnumber in my case worked, as I previously used hostname:portname (courtesy from the JDBC API) to connect with my local db.
So by specifying the portnumber as its own variable, instead of appending it on hostname, you might be able to connect to it.
Let me know if it doesn't work.
var connection = mysql.createConnection({
host : "hostname",
port : "portnumber",
user : "username",
password : "password",
database : "dbname"
});