Question

I'm getting this login error: Warning: mysqli::mysqli() [mysqli.mysqli]: (28000/1045): Access denied for user 'user'@client-ip' (using password: YES) in.

This happens no matter what I set in Cpanel. I've reset the passwords, created new users with all privileges.

I'm not that familiar with Cpanel but have created and reset user passwords for db users.

Using Cpanel... Do not have hosting access. Just FTP Access and access to Cpanel / PhpMyAdmin

I have looked and looked and it only seems that this could be an install problem with the permissions table or something of the sort... https://dev.mysql.com/doc/refman/5.1/en/access-denied.html

Not sure if I can access the console.

Here is my php for reference sake:

// try connect to the MySQL database
$mysqli = new mysqli($dbhost, $dbuser, $dbpass, $dbname);
// var to check for duplicate txn - default false
$exists = false;
// check connection to database
if ($mysqli->connect_errno) { // false - database doesn't exist
    $error = $mysqli->connect_errno;
} else { // database exists
        $res = $mysqli->query("SELECT * FROM paypal_txn_log WHERE txn_id = '$txn_id'");
        $exists = $res->num_rows;
        // doesn't exist insert transaction number entry
        if (!$exists) {
            $time = date('Y-m-d H:i:s');
            $query = "INSERT INTO paypal_txn_log (txn_id, customer_email, datetime) VALUES ('$txn_id', '$payer_email', '$time')";
            $mysqli->query($query);
            $mysqli->close();
        }
}
Was it helpful?

Solution

MYSQL makes a difference between local and remote users.

GRANT <some privileges> TO '<username>' ON <database>.<table> ...

Will only grant access local user that talk to mysql via sockets

GRANT <some privileges> TO '<username>'@'<some ip>' ON <database>.<table> ...

will allow a user connecting via TCP/IP from that ip

GRANT <some privileges> TO '<username>'@'%' ON <database>.<table> ...

will allow user to connect from every

on the mysql shell, you will have to run

FLUSH PRIVILEGES

to make changes done with grant effective

As far as cpanel and phpmyadmin goes (which cpal uses) , these frameworks do the last step automatically if you add a user.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top