我收到此登录错误:Warning: mysqli::mysqli() [mysqli.mysqli]: (28000/1045): Access denied for user 'user'@client-ip' (using password: YES) in
。MySQL登录错误警告
无论我在Cpanel中设置了什么,都会发生这种情况。我已重置密码,创建具有所有权限的新用户。
我并不熟悉Cpanel,但已经为db用户创建和重置用户密码。
使用Cpanel ...不具有主机访问权限。只是FTP访问和访问交友/ phpMyAdmin的
我已经找了又找,它只是似乎这可能是一个安装与权限表或类似的东西的问题... https://dev.mysql.com/doc/refman/5.1/en/access-denied.html
不知道如果我可以访问控制台。
这里是我的,为了参考PHP:
// 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();
}
}
您的代码(最有可能)开放给SQL注入。请不要将变量直接粘贴到查询中,而是使用预准备语句和绑定变量。 – h2ooooooo
您已创建用户,数据库并重置密码。在cPanel中,我经常忽略的一件事是在该特定数据库上授予特定用户权限。 [cPanel文档](http://docs.cpanel.net/twiki/bin/view/AllDocumentation/CpanelDocs/MySQLDatabases)。 – jonnu
另外,你在'client-ip'连接 - 确保你在该IP上授予,而不是'localhost'!或者,授予'%'。 – jonnu