0

我使用我的网站提供商在我的网站上创建了一个论坛,它为我创建了数据库并上传了论坛等。以前我上传了论坛并自己创建了数据库,但由于某种原因,phpbb3的发布充满了诸如丢失之类的东西?>标签

我正在尝试使用我自己的脚本连接到数据库,我创建了一些其他数据库,它们工作正常,除了这个由我的提供商制作的数据库

$con = mysql_connect('ip','user','pass');
if (!$con) {
    die('Not connected : ' . mysql_error());
}

$db_selected = mysql_select_db('forum',$con);
if (!$db_selected) {
    die ('Can\'t use db : ' . mysql_error());
}

我明白了Can't use db : Access denied for user 'user'@'%' to database 'forum'

编辑:(已修复)缺少名为 $db_selected 的变量

4

1 回答 1

1

Assuming that the user you want to use to access the database is called "user", check the following

1) Switch current db to mysql, and check if the user exists (there is a row having Host = % in the results of the following query)

USE mysql;
SELECT * FROM user WHERE user = 'user'

2) Check if this user has permissions for the database (there is a row having Db = database and host = %)

SELECT * FROM db WHERE user = 'user'

3) If this looks fine, try to flush privileges by the following:

FLUSH PRIVILEGES;

Then try to log in .. it may help.

The full step by step how to create a user and grant privileges is here:

http://dev.mysql.com/doc/refman/5.1/en/adding-users.html

于 2013-07-21T09:17:13.520 回答