警告:mysqli_connect():(HY000/1044):用户'@'localhost'对数据库'dbtest'的访问被拒绝 [英] Warning: mysqli_connect(): (HY000/1044): Access denied for user ''@'localhost' to database 'dbtest'

查看:1328
本文介绍了警告:mysqli_connect():(HY000/1044):用户'@'localhost'对数据库'dbtest'的访问被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试连接到我的SQL Server时,它给了我错误:

When i try to connect to my sql server, it gives me the error:

警告:mysqli_connect():(HY000/1044):拒绝用户``@'localhost'访问数据库'dbtest'.

Warning: mysqli_connect(): (HY000/1044): Access denied for user ''@'localhost' to database 'dbtest'.

我刚刚创建了用户并授予了所有权限,但是我仍然努力工作.在使用另一个帐户之前,但是我无法更改它的数据库权限.有人有可能解决问题吗?

I just created the user and gave it all permissions, but i still dosent work. Before i used another account, but i couldn't change the database perssions for it. Anybody who have a potential fix?

这是连接代码.

<?php

    // this will avoid mysql_connect() deprecation error.
    error_reporting( ~E_DEPRECATED & ~E_NOTICE);
    // but I strongly suggest you to use PDO or MySQLi.

    $DBHOST= "localhost";
    $DBUSER= "testadmin";
    $DBPASS= "";
    $DBNAME= 'dbtest';

    $conn = mysqli_connect(localhost, testadmin, $DBPASS, dbtest);
//  $dbcon = mysql_select_db($DBNAME);

    if ( !$conn ) {
        die("Connection failed : " . mysql_error());
    }

?>

推荐答案

我知道此线程很旧,但是Ahmad Sharif是正确的.快速解决此问题的最佳方法(尤其是与新托管公司合作的情况)是使用cPanel中的"MySQL数据库向导" 创建一个新数据库,然后向所有人授予所有特权以确保远程访问将正常进行.通过"MySQL数据库向导"创建新数据库时,只需确保选中所有复选框即可.

I know this thread is old, but Ahmad Sharif is correct. The best way to quickly resolve this issue, especially if you're with a new hosting company, is to just create a new database using the "MySQL Database Wizard" in cPanel, then grant ALL privileges to everyone to ensure the remote access will work. Just make sure that ALL check boxes are checked while creating the new database from the "MySQL Database Wizard".

这篇关于警告:mysqli_connect():(HY000/1044):用户'@'localhost'对数据库'dbtest'的访问被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆