【问题标题】:Unable to connect to mysql while installing phabricator安装phabricator时无法连接到mysql
【发布时间】:2015-01-20 18:24:42
【问题描述】:

我正在 linux 中安装 phabricator,并按照 https://secure.phabricator.com/book/phabricator/article/installation_guide/http://www.tecmint.com/install-phabricator-in-linux/ 的安装指南进行操作

当我尝试从 web url 访问 phabricator 时,我得到了类似的响应

    Unable to connect to MySQL!

     Attempt to connect to root@127.0.0.1 failed with error #2003: Can't connect to MySQL server on '127.0.0.1' (13).

     Make sure Phabricator and MySQL are correctly configured.

To update these 4 value(s), run these command(s) from the command line:
phabricator/ $ ./bin/config set mysql.host value
phabricator/ $ ./bin/config set mysql.port value
phabricator/ $ ./bin/config set mysql.user value
phabricator/ $ ./bin/config set mysql.pass value

当我配置我的 mysql 并且如果我运行 phabricator/ $ ./bin/storage upgrade 我得到错误

   [2015-01-20 18:12:04] EXCEPTION: (AphrontAccessDeniedQueryException) #1044: Access denied for user ''@'localhost' to database 'phabricator_audit' at [<phutil>/src/aphront/storage/connection/mysql/AphrontBaseMySQLDatabaseConnection.php:301]
  #0 AphrontBaseMySQLDatabaseConnection::throwQueryCodeException(integer, string) called at [<phutil>/src/aphront/storage/connection/mysql/AphrontBaseMySQLDatabaseConnection.php:275]
  #1 AphrontBaseMySQLDatabaseConnection::throwQueryException(mysqli) called at [<phutil>/src/aphront/storage/connection/mysql/AphrontBaseMySQLDatabaseConnection.php:181]
  #2 AphrontBaseMySQLDatabaseConnection::executeRawQuery(string) called at [<phutil>/src/xsprintf/queryfx.php:6]
  #3 queryfx(AphrontMySQLiDatabaseConnection, string, string) called at [<phabricator>/src/infrastructure/storage/management/PhabricatorStorageManagementAPI.php:219]
  #4 PhabricatorStorageManagementAPI::applyPatchSQL(string) called at [<phabricator>/src/infrastructure/storage/management/workflow/PhabricatorStorageManagementUpgradeWorkflow.php:109]
  #5 PhabricatorStorageManagementUpgradeWorkflow::execute(PhutilArgumentParser) called at [<phutil>/src/parser/argument/PhutilArgumentParser.php:396]
  #6 PhutilArgumentParser::parseWorkflowsFull(array) called at [<phutil>/src/parser/argument/PhutilArgumentParser.php:292]
  #7 PhutilArgumentParser::parseWorkflows(array) called at [<phabricator>/scripts/sql/manage_storage.php:171]

如果我运行./bin/storage upgrade --user root --password root,我会收到错误

Raw MySQL Error: Attempt to connect to root@localhost failed with error
#1045: Access denied for user 'root'@'localhost' (using password: YES).

这是我的 apache 设置,

<VirtualHost *:80>
        ServerAdmin root@xxx.yyy.com
        ServerName xxx.yyy.com
        DocumentRoot /var/www/html/myprojectapp/phabricator/webroot
        RewriteEngine on
        RewriteRule ^/rsrc/(.*)     -                       [L,QSA]
        RewriteRule ^/favicon.ico   -                       [L,QSA]
        RewriteRule ^(.*)$          /index.php?__path__=$1  [B,L,QSA]
<Directory "/var/www/html/myprojectapp/phabricator/webroot">
        Order allow,deny
        Allow from all
</Directory>
</VirtualHost>

我已按照安装指南中提供的所有说明进行操作。谁能帮我指出我的错误?

【问题讨论】:

  • 您尝试将mysql.hostmysql.passmysql.portmysql.user 设置为bin/config set
  • 感谢您的快速回复。是的,我做到了:(当我运行存储升级时,我得到了错误
  • 您是否尝试过使用127.0.0.1 作为主机而不是localhost 您也可以使用相同的凭据(即mysql -u username -p -h hostname)连接命令行mysql 客户端吗?
  • 我按照您的建议尝试并收到以下错误,[root@codereview phabricator]# ./bin/storage upgrade MySQL Credentials Not Configured 无法使用配置的凭据连接到 MySQL。您必须先配置标准凭据,然后才能升级存储。运行这些命令来设置凭据:原始 MySQL 错误:尝试连接到 root@127.0.0.1 失败,错误 #1045:用户 'root'@'localhost' 的访问被拒绝(使用密码:是)。 [root@codereview phabricator]#
  • 将 mysql.host 设置为 127.0.0.1 而不是 @prodigitalson 建议的 localhost 解决了我的问题。谢谢!

标签: php mysql linux apache phabricator


【解决方案1】:

Phabricator 似乎创建了 很多 phabricator_ 数据库,所以这应该可以解决问题:

GRANT ALL PRIVILEGES ON `phabricator\_%`.* TO phabricatoruser@'localhost';

您也可以尝试限制权限。

【讨论】:

  • 无需授予 Phabricator 用户对 all 数据库的所有权限。 Phabricator 在phabricator_ 命名空间内创建表。因此,将 Phabricator 帐户权限限制到该命名空间会更安全。请改用以下命令:grant all privileges on `phabricator\_%`.* to phabricatoruser@'localhost';
【解决方案2】:

我遇到了同样的问题,解决起来很容易:

./bin/config set mysql.host 'localhost'

./bin/config set mysql.user 'root'

./bin/config set mysql.pass 'pass'

不要忘记我花了 2 天时间来解决这个问题的“报价”!!

【讨论】:

  • 将 root 权限授予 Web 应用程序并不是一个好主意。
【解决方案3】:

这是一个 selinux 问题。 禁用它可以解决它。 1 编辑这个文件 vim /etc/selinux/config 2 改变 SELINUX=enforcing ---> SELINUX=disabled 3 重启

【讨论】:

    【解决方案4】:

    您的数据库用户很可能没有创建权限。

    使用mysql登录:mysql -u user -p 并尝试:create database temp;

    如果数据库没有被创建,那么你需要给你的用户授予创建权限。

    检查this 获取 mysql Grant 语法。

    【讨论】:

      【解决方案5】:

      好的,我刚遇到同样的问题,我在几个小时后修复了它:(

      好像我的密码末尾有美元符号$

      我把mysql密码改成了简单的字母和数字,没有特殊字符。

      奇怪,但这解决了我的问题!

      我没有做任何额外的调查,但似乎是 mysql 密码中的特殊字符有问题。

      【讨论】:

        猜你喜欢
        • 2015-10-31
        • 2016-04-13
        • 2014-04-18
        • 1970-01-01
        • 2020-02-22
        • 2019-02-06
        • 1970-01-01
        • 1970-01-01
        • 2017-11-07
        相关资源
        最近更新 更多