用户@“localhost”对数据库的访问被拒绝

时间:2022-05-28 03:06:25

I'm seeing a lot of of similar questions to this. but can't find one exactly like mine yet. Not sure where to change these settings or anything, any help appreciated.

我看到了很多类似的问题。但是我还找不到一个和我一样的。不知道该在哪里更改这些设置或任何东西,任何帮助都值得赞赏。

access denied Access denied for user ''@'localhost' to database ''

This is the beginning of my page.

这是我的页面的开始。

$dbhost = 'localhost'; //unlikely to require changing.
$dbname ='publication'; //modify these
$dbuser = 'username'; //variables 
$dbpass = ''; //// to your installation
$appname = 'application name'; // and preference

mysql_connect($dbhost, $dbuser, $dbpass) or die(mysql_error());
mysql_select_db($dbname) or die(mysql_error());

2 个解决方案

#1


17  

Try this: Adding users to MySQL

试试这个:将用户添加到MySQL。

You need grant privileges to the user if you want external acess to database(ie. web pages).

如果您想要外部acess到数据库(ie),您需要给用户授予特权。web页面)。

#2


4  

You are most likely not using the correct credentials for the MySQL server. You also need to ensure the user you are connecting as has the correct privileges to view databases/tables, and that you can connect from your current location in network topographic terms (localhost).

您很可能没有使用MySQL服务器的正确凭据。您还需要确保您所连接的用户具有查看数据库/表的正确权限,并且您可以在网络地形条件(localhost)中从当前位置连接。

#1


17  

Try this: Adding users to MySQL

试试这个:将用户添加到MySQL。

You need grant privileges to the user if you want external acess to database(ie. web pages).

如果您想要外部acess到数据库(ie),您需要给用户授予特权。web页面)。

#2


4  

You are most likely not using the correct credentials for the MySQL server. You also need to ensure the user you are connecting as has the correct privileges to view databases/tables, and that you can connect from your current location in network topographic terms (localhost).

您很可能没有使用MySQL服务器的正确凭据。您还需要确保您所连接的用户具有查看数据库/表的正确权限,并且您可以在网络地形条件(localhost)中从当前位置连接。