【问题标题】:Connect to database fail from wordpress in wampserver从 wampserver 中的 wordpress 连接到数据库失败
【发布时间】:2016-08-17 17:48:38
【问题描述】:

我将 wp-config 更改为以下设置

define('DB_Name', 'wp');
define('DB_User', 'root');
define('DB_PASSWORD', '');
define('DB_HOST', 'localhost:3306');
define('DB_CHARSET', 'utf8');
define('DB_COLLATE', '');

我收到以下错误消息

警告:mysqli_real_connect(): (HY000/1045): Access denied for user 'DB_USER'@'localhost' (using password: NO) in C:...\wp-includes\wp-db.php on line第1489章

当我将“localhost”更改为“myipaddress”时

我收到以下错误消息

警告:mysqli_real_connect(): (HY000/1130): Host 'xxx' is not allowed to connect to this MySQL server in C:...\wp-includes\wp-db.php on line 1489

但是,我可以只使用用户名“root”而不使用密码登录到 phpAdmin 来创建一个新数据库。我也可以通过MYSQL控制台无密码进入mysql

我可以做些什么来解决这个问题?如何授予权限?

谢谢,

【问题讨论】:

  • 尝试使用 insted localhost 127.0.0.1 作为 mysql 主机
  • 我把它改成了 127.0.0.1 我得到了同样的错误信息。 mysqli_real_connect(): (HY000/1045): Access denied for user 'DB_USER'@'localhost' (using password: NO) in C:..\wp-includes\wp-db.php on line 1489
  • 您是否在数据库中使用过密码,因为它显示密码不匹配,并且曾经只使用没有端口 3306 的 localhost。

标签: mysql wordpress wampserver


【解决方案1】:

如有疑问check the manual

那会告诉你的

define('DB_Name', 'wp');
define('DB_User', 'root');

应该是

define('DB_NAME', 'wp');
define('DB_USER', 'root');

【讨论】:

  • 好点我省略了阅读那些行!这些是特定的 wordpress 常量
猜你喜欢
  • 2012-03-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-07-14
  • 2013-07-04
  • 2016-11-15
  • 2013-05-08
  • 1970-01-01
相关资源
最近更新 更多