【问题标题】:MySQL Emoncms PHP Error: User Password:NOMySQL Emoncms PHP 错误:用户密码:否
【发布时间】:2018-09-29 02:25:20
【问题描述】:

我正在尝试让 Emoncms 在具有经过验证的先决条件(如 mod_rewrite 和 LAMP 服务器)的共享托管 MediaTemple 网络服务器上工作。我已经使用用户名和密码创建了数据库,并尽我所能配置了settings.php

/ - this is root
/emoncmsdata - Its 777 for data folders /phpfina & /phpfiwa & /phptimeseries
/httpdocs - this is my public folder
/httpdocs/emoncms - this is where the settings.php is and where modules are

但是当我访问 santiapps.com/emoncms/ 我得到:

无法连接到数据库,请在 settings.php 中验证凭据/配置

错误消息:用户“marskoko”@“localhost”的访问被拒绝(使用密码:否)。

我已将数据库、用户和密码放入脚本中。我已经检查过了,并通过他们的 plesk 重置了密码。

  1. 我知道该用户的密码是正确的,因为我可以通过终端使用 mysql -u user -p pass 使用密码登录,我得到 MariaDB 服务器,然后我可以输入 USE Emoncms 并且提示显示我已连接到 Emoncms

  2. 应用程序创建的emoncms.log 文件为空。我在 web 服务器的 error.log 中发现了一堆这样的:

    [2018 年 9 月 28 日星期五 20:53:23.620729] [proxy_fcgi:error] [pid 8219:tid 140039956670208] [client 83.139.179.122:35214] AH01071: 出现错误‘Primary script unknown\n’

  3. 我已经检查了 SO 中关于这个用户密码的大部分帖子:没有问题,它们都与 root 相关,但我不是。我正在使用另一个名为 marskoko 的用户。

    Access denied for user 'root'@'localhost' (using password: NO)?Unable to authenticate php/Mysql?

  4. 我无法停止或启动服务器,我尝试了 service mysql stop 并得到:

    重定向到 /bin/systemctl stop mysql.service

    无法停止 mysql.service:未加载单元 mysql.service。

    4.a) 最近有人建议我尝试:

    service mysqld restart
    

    但我得到一个类似的错误:

    重定向到/bin/systemctl restart mysqld.service

    重启 mysqld.service 失败:未找到单元。

    但我知道它正在运行,否则我将无法查看我的其他数据库。

  5. 我已经创建了这个 php 文件:

    <?php
    $db = mysqli_connect("localhost","marskoko","myPasshasAdollarSign") or die("Failed to open connection to MySQL server.");
    mysqli_select_db($db, "emoncms") or die("Unable to select database");
    \> 
    

    然后运行它,我得到了这个:

    无法打开与 MySQL 服务器的连接。

    5.a) 当我使用mysqli_connect_error() 时,我得到:

    拒绝用户 'emonuser'@'localhost' 的访问(使用密码:否)

    注意:用户不同,因为我想确保数据库或用户没有问题,所以我删除了数据库并重新创建并更改了用户名。数据库仍然存在,我仍然可以使用 mysql 命令和相同的密码通过 MariaDB 访问它。

  6. 我试过这个建议:

    ps aux | grep mysql

    我明白了:

    mysql     7766  0.0  0.0 113200  1588 ?        Ss   Sep28   0:00 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
    mysql     8286  0.7  5.4 1906888 457400 ?      Sl   Sep28   5:12 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/lib/mysql/activacorp.net.err --pid-file=activacorp.net.pid --socket=/var/lib/mysql/mysql.sock --port=3306
    root     15702  0.0  0.0 112600  1068 pts/0    S+   09:17   0:00 grep --color=auto mysql
    
  7. 我刚刚尝试使用用户/密码登录数据库,并尝试获取用户表,但得到了这个:

    MariaDB [emoncms]> select * from user;
    ERROR 1146 (42S02): Table 'emoncms.user' doesn't exist
    

然后我再次检查了我所有的数据库,但其中都没有 users 表。他们有我添加和使用的其他表,但没有用户表。也许 phpmyadmin 隐藏了这一点,我不知道。

我不知道还有什么可以尝试的。

【问题讨论】:

    标签: php mysql


    【解决方案1】:

    我认为您可以通过以下步骤解决此问题

    1. 使用 service mysqld start/stop/restart 而不是 service mysql start/stop/restart 来启动/停止 mysql

    2. 确保你的mysql用户密码正确-root,如果没有,请按照步骤3重置密码,否则跳过步骤3

    3. 编辑mysql配置文件,一般是/etc/my.cny,在[mysqld]下添加skip-grant-tables,然后重启mysql,现在可以不用密码进入mysql,然后用

      重置密码>

      update mysql.user set authentication_string=password('123qwe') where user='root' and Host = 'localhost';

      刷新权限;

    4. 就是这样,请检查一下

    【讨论】:

    • 我确实有该用户的正确密码。我已经重置它并像我说的那样通过终端尝试了它,所以我知道它是该用户的正确密码。使用该命令重新启动也不起作用。我更新了我的帖子...关于 root 用户,你为什么要问我关于 root 用户的问题,我使用的是我为这个数据库创建的用户,即 marskoko
    • 没有区别所以你有两个问题吗? 1. 如何重启mysql 2. 为什么会出现连接错误 1. exec ps aux | grep mysql 看看mysql 是如何启动的 2. $db = mysqli_connect("localhost","marskoko","myPasshasAdollarSign") or die(mysqli_connect_error()); 得到具体原因然后请告诉我所有结果
    • 那我就不用重新设置密码了,通过mysql命令登录确认密码确实正确
    • 好的,我尝试了 ps aux 和 mysqli 命令并更新了 OP
    • 我能够以某种方式使用 mysqli_connect() 摆脱错误。现在我还能尝试什么?
    【解决方案2】:

    好的,我想通了。挖掘 php 我尝试在 emoncms 的 index.php 中记录 $password 变量,它记录为空白,而用户名、数据库或其他变量正确记录。我最终将 $password 替换为 mysqli 行中的实际密码,现在它可以工作了。所以我只是将 $password "" 替换为 '',它现在可以工作了。

    【讨论】:

      猜你喜欢
      • 2011-07-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-02-12
      • 2017-01-08
      相关资源
      最近更新 更多