【问题标题】:phpBB and mySQL "Could not connect to the database..."phpBB 和 mySQL “无法连接到数据库...”
【发布时间】:2016-08-16 05:29:20
【问题描述】:

我正在尝试在本地托管的网页上建立一个 phpBB 论坛。它是在 openSUSE Linux 操作系统中完成的。

我已经安装了 MariaDB (MySQL),并使用命令 CREATE DATABASE new_database; 创建了一个名为 new_database 的新数据库,并使用命令 CREATE USER 'new_user'@'localhost' IDENTIFIED BY 'password'; 创建了一个名为 user 的用户。我还把root密码改成了password,只是为了测试。

当我将此信息输入到 phpBB 安装数据库设置屏幕时,我收到错误提示

无法连接到数据库,请参阅下面的错误消息。

拒绝用户“new_user”@“localhost”访问数据库“new_database”。

我使用localhost 作为 DSN。有任何想法吗?从我在网上找到的所有内容来看,它应该可以工作......

【问题讨论】:

    标签: php mysql phpbb


    【解决方案1】:

    创建用户后,您必须授予权限,您就是这样做的。

    GRANT ALL PRIVILEGES ON new_database.* TO 'newuser'@'localhost';
    

    别忘了冲洗。

    FLUSH PRIVILEGES
    

    通用权限

    ALL PRIVILEGES- all access
    CREATE- allows them to create new tables or databases
    DROP- allows them to them to delete tables or databases
    DELETE- allows them to delete rows from tables
    INSERT- allows them to insert rows into tables
    SELECT- allows them to use the Select command to read through databases
    UPDATE- allow them to update table rows
    GRANT OPTION- allows them to grant or remove other users' privileges
    

    可以指定数据库和表。

    new_database.* (Specific Database, all tables)
    new_database.table (Specific Database, specific table)
    *.* (all databases, al tables)
    

    【讨论】:

      【解决方案2】:

      我在安装 phpBB 时遇到了同样的问题,通过 phpMyAdmin 访问数据库并注意到启动页面上显示“用户:pits@localhost”,这与我创建的用户 (pits_bull) 不同,从而解决了这个问题并附加到数据库并尝试连接。

      我只用“坑”进行了尝试,它奏效了。不确定这是否存在安全问题,或者它为什么有效,但它确实有效!

      【讨论】:

        猜你喜欢
        • 2011-03-23
        • 2016-12-03
        • 2014-01-25
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-02-06
        • 2016-12-13
        相关资源
        最近更新 更多