【问题标题】:Use a online database for my localhost wordpress为我的本地主机 wordpress 使用在线数据库
【发布时间】:2019-04-12 15:42:11
【问题描述】:

我必须和朋友一起在 wordpress 项目中工作,我们希望能够在 localhost 中与我们身边的每个人一起工作。 为此,我们使用 git 来拥有相同的代码,但我们需要使用相同的数据库。 我在线创建了一个数据库:

https://xxxx.xxxxxx.com/phpmyadmin

我将我的 wp-conf 文件编辑成这样:

define( 'DB_NAME', 'db_name' );

define( 'DB_USER', 'admin' );

define( 'DB_PASSWORD', '******' );

define( 'DB_HOST', 'https://xxxx.xxxxxx.com' );

我已经尝试过:

define( 'DB_HOST', 'xxxx.xxxxxx.com/phpmyadmin' );

define( 'DB_HOST', 'http://xxxx.xxxxxx.com' );

define( 'DB_HOST', 'http://xxxx.xxxxxx.com/phpmyadmin' );

等等……

谢谢,

本杰明。

【问题讨论】:

  • 检查与您的托管服务提供商的连接详细信息。他们会告诉您在外部连接到数据库时需要使用哪个主机。

标签: database wordpress configuration phpmyadmin config


【解决方案1】:

如果你参考这里的代码 https://codex.wordpress.org/Editing_wp-config.php 来设置你的 DB_HOST

格式应该是

define( 'DB_HOST', 'the_ip_of_the_server' );

或者在某些情况下,如果您需要设置端口。

define( 'DB_HOST', 'mysql.example.com:3307' );

If your host uses Unix sockets or pipes, adjust the DB_HOST value in the wp-config.php file accordingly.

define( 'DB_HOST', '127.0.0.1:/var/run/mysqld/mysqld.sock' );
// or define( 'DB_HOST', 'localhost:/var/run/mysqld/mysqld.sock' );
// or define( 'DB_HOST', 'example.tld:/var/run/mysqld/mysqld.sock' );

【讨论】:

    【解决方案2】:

    要解决这个问题:我只是将数据库公开。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-10-27
      • 2020-08-02
      • 1970-01-01
      • 2013-02-24
      • 2019-08-08
      • 1970-01-01
      • 2015-06-13
      • 2012-10-18
      相关资源
      最近更新 更多