简体   繁体   中英

Connect Error (1044) Access denied for user

I have a site on WordPress, and I need to execute one PHP file on it but I get this error:

Warning: mysqli::mysqli(): (42000/1044): Access denied for user 'topimobiliare_ad'@'localhost' to database 'topimobilare' in /home/topimobiliare/public_html/create_feed_cron_job.php on line 11
Connect Error (1044) Access denied for user 'topimobiliare_ad'@'localhost' to database 'topimobilare'

Login, pass, server and db_name are from the wp_config.php file. I don't know what's wrong.

Connection code:

$dbhost="localhost";
$dbuser="topimobiliare_ad";
$dbpassword="hidden";
$dbname="topimobilare";

$mysqli = new mysqli($dbhost, $dbuser, $dbpassword, $dbname);
$mysqli->set_charset("utf8");
if ($mysqli->connect_error) {
    die('Connect Error (' . $mysqli->connect_errno . ') ' . $mysqli->connect_error);
}

There is two possibility.

1). The user does not exist.

2). Second is user grant issue.

If the user has any grant related issue then you can give grant as per following.

GRANT ALL PRIVILEGES ON database.* TO 'admin'@'localhost';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM