CPanel : Access denied for user 'root'#'localhost' (using password: NO) - sql

I'm getting this error over and over again. I'm using CPanel.
Connection failed: SQLSTATE[28000] [1045] Access denied for user 'root'#'localhost' (using password: NO)
My code in connection file:
$dsn = 'mysql:dbname=mydomain_xxx;host=localhost';
$user = 'mydomain_yyy';
$password = 'password';

Related

Uncaught PDOException: SQLSTATE[HY000] [1045] Access denied for user 'dbuser'#'localhost' (using password: YES)

Most answers were that it would be a right issue. But I assume not in this case, because mysql-connection still worked.
I am trying to connect to a mariadb10, which was on a server in my network
I am trying to connect from my localhost.
If I try in my terminal:
myuser#mylocalComputer ~ $ mysql -h myserver -P 3307 -u mydbuser -pmyconfidentalpassword
everything works fine!!
But If I try to connect by php scrypt by pdo I get the error:
<?php
$dsn = 'mysql: host=myserver:3307;dbname=mydbname';
$username = 'mydbuser';
$password = 'myconfidentalpassword';
$options = array(
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',
);
$dbh = new PDO($dsn, $username, $password, $options);
if(! $dbh ) {
die('Could not connect: ' . mysql_error());
}
$sql = 'select * from foo;';
$retval = mysql_query( $sql, $conn );
if(! $retval ) {
die('Could not select data: ' . mysql_error());
}
echo "Synced data successfully\n";
mysql_close($conn);
?>
The Error was:
PHP Fatal error: Uncaught PDOException: SQLSTATE[HY000] [1045] Access
denied for user 'mydbuser'#'localhost' (using password: YES) in
/home/myuser/Projekte/Hibiscus_extend/Hib_Nightly_sync.php:8
Stack trace:
/home/myuser/Projekte/Hibiscus_extend/Hib_Nightly_sync.php(8):
PDO->__construct('mysql: host=myse...', 'mydbuser',
'myconfidentalpassword', Array) {main} thrown in
/home/myuser/Projekte/Hibiscus_extend/Hib_Nightly_sync.php on line 8
What did I do wrong, and where?
Oh Oh Oh!
I found the solution!
The reason for the connection problem were just the empty spaces in $dsn
Wrong:
$dsn = 'mysql: host=myserver:3307;dbname=mydbname';
works fine
$dsn = 'mysql:host=myserver:3307;dbname=mydbname';

Symfony 3 : Doctrine:schema:update returns ConnexionException

on a machine with IP 178.33.13.83, i have a symfony app with the following parameters.yml :
parameters:
database_host: 178.33.13.80
database_port: null
database_name: alterxtn
database_user: alterxtn
database_password: ********************
But then when i try to doctrine:schema:update i recieve the following exception :
[Doctrine\DBAL\Exception\ConnectionException]
An exception occured in driver: SQLSTATE[HY000] [1045] Access denied
for user 'alterxtn'#'178.33.13.83' (using password: YES)
I'm wondering why it's trying to connect to the machine the app is installed on and not on the database_host
[Edit 1]:
here the exception with stacktrace, and please notice especially the Driver->connect() function that's taking the good params :
ConnectionException in AbstractMySQLDriver.php line 103:
An exception occured in driver: SQLSTATE[HY000] [1045] Access denied for user 'alterxtn'#'178.33.13.83' (using password: YES)
in AbstractMySQLDriver.php line 103
at AbstractMySQLDriver->convertException('An exception occured in driver: SQLSTATE[HY000] [1045] Access denied for user 'alterxtn'#'178.33.13.83' (using password: YES)', object(PDOException)) in DBALException.php line 145
at DBALException::driverException(object(Driver), object(PDOException)) in Driver.php line 47
at Driver->connect(array('driver' => 'pdo_mysql', 'host' => '178.33.13.80', 'port' => null, 'dbname' => 'alterxtn', 'user' => 'alterxtn', 'password' => '**********************************', 'charset' => 'UTF8', 'driverOptions' => array(), 'defaultTableOptions' => array()), 'alterxtn', '******', array()) in Connection.php line 360
[EDIT 2] :
i have the same error in shell so probably not a symfony problem
me#mymachine:$ mysql -h 178.33.13.80 -u alterxtn
ERROR 1045 (28000): Access denied for user 'alterxtn'#'178.33.13.83' (using password: YES)
It was my mistake.
The sql-user was set to server-privilege localhost
Setting it to % solved the issue.

how to extend lifetime of a meteor login token?

I have a meteor app that seems to force a logout after 24 hours.
Our app (in beta) is using a "guest login" process where we create accounts on the fly, so i want to actually have an indefinite token lifetime.
Is there a way to extend the lifetime of these tokens?
Error logging in with token: Error: You've been logged out by the server. Please log in again. [403]
update failed: Access denied
Our guest login looks something like this:
postCreateUser = (username, password) ->
dclib.clog("login", "created", username)
Meteor.loginWithPassword username, password, ->
# FIXME? could this be in onCreateUser server side?
Meteor.call "createPersonalRoomIfNone"
if Meteor.isClient
Meteor.startup ->
unless Meteor.userId()
Meteor.call "getLastUserIndex", (err,index)->
if err
throw err
console.log("creating guest user", index)
username = "Guest #{index}"
password = Random.id()
Accounts.createUser
username: username
email: ""
password: password
role: "guest"
, -> postCreateUser(username, password)
this does it i hope!
# prevent users getting logged out
# http://devdocs.io/meteor/index#accounts_config
Accounts.config ({loginExpirationInDays: null})

Lsyncd Permission denied (publickey,password)

I am setting up lsyncd at for automatic sync local and remote folders. I have researched for many solution available, also adding extra params to the conf file.
I have also, updated the sshd_config with PermitRootLogin without-password
Also, I am able to ssh with password and also rsync without password manually tried but the problem is when I use it via lsyncd it give permission denied error 3 times and exit (seems like its asking for password).
lsyncd.conf.lua file
settings {
logfile = "/var/log/lsyncd/lsyncd.log",
statusFile = "/var/log/lsyncd/lsyncd.status",
statusInterval = 10
}
sync {
default.rsync,
source="/home/gaurav/Desktop/source/",
target="root#xxx.xxx.xx.xxx:/root/destination/",
rsync = {
compress = true,
acls = true,
verbose = true,
_extra = {"-P", "-e", "/usr/bin/ssh -p 22 -i /home/gaurav/.ssh/id_rsa -o StrictHostKeyChecking=no"}
}
}
Also tried with this one also.
settings = {
logfile = "/var/log/lsyncd/lsyncd.log",
statusFile = "/var/log/lsyncd/lsyncd.status"
}
sync {
default.rsyncssh,
source = "/home/gaurav/Desktop/source/",
host = "xxx.xxx.xx.xxx",
targetdir = "/root/destination/"
}
Logs
Sun Dec 7 17:18:09 2014 Normal: recursive startup rsync: /home/gaurav/Desktop/source/ -> root#xxx.xxx.xx.xxx:/root/destination/
Permission denied, please try again.
Permission denied, please try again.
Permission denied (publickey,password).
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.1]
Sun Dec 7 17:18:12 2014 Error: Temporary or permanent failure on startup of "/home/gaurav/Desktop/source/". Terminating since "insist" is not set.
If you are using ubuntu 12.04 you must use rsyncOps instead rsync = {} block.
Try this:
sync {
default.rsync,
source="/var/www/",
target=server..":/var/www/",
excludeFrom="/etc/lsyncd/lsyncd-excludes.txt",
rsyncOps={"-e", "/usr/bin/ssh -o StrictHostKeyChecking=no", "-avz"}
}
https://www.stephenrlang.com/2015/12/how-to-install-and-configure-lsyncd/

How to connect to another mysql server using mysql_connect

is it possible to connect to another mysql server using mysql_connect function?
this is my code
$dbHost = "192.168.1.2:3306";
$dbUser = "root";
$dbPass = "pass";
$con = mysql_connect($dbHost, $dbUser, $dbPass);
and i got this mysql error
Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'root'#'192.168.1.9' (using password: YES)