簡體   English   中英

與WordPress和Azure建立數據庫連接時出錯

[英]Error establishing a database connection with WordPress and Azure

我已經在Azure上托管了一個WordPress網站http://edufunweb.azurewebsites.net/ 在我想托管另一個站點之前,它運行良好。 因此,我轉到了Microsoft Webmatrix中的edufun wp-config.php文件並更改了該行

$table_prefix = 'wp_';

$table_prefix  = 'wp_2';

(或者反之亦然),以便每個站點的數據庫中都有不同的表。 然后,我刪除了另一個站點,現在使用上面的任何代碼,我都會得到一個

Warning: mysql_connect(): Access denied for user 'abcd'@'xxx.yyy.zzz.xx' (using password: YES) in D:\home\site\wwwroot\wp-includes\wp-db.php on line 1461
Error establishing a database connection
This either means that the username and password information in your wp-config.php file is incorrect or we can't contact the database server at eu-cdbr-azure-north-c.cloudapp.net. This could mean your host's database server is down.

Are you sure you have the correct username and password?
Are you sure that you have typed the correct hostname?
Are you sure that the database server is running?
If you're unsure what these terms mean you should probably contact your host. If you still need help you can always visit the WordPress Support Forums.

此外,如果我連接到http://edufunweb.azurewebsites.net/wp-admin/

我仍然遇到相同的錯誤。

非常感謝您的幫助,因為我需要我的網站恢復正常!

我認為這不是WP多站點問題。 這通常是由於與主機mysql服務器的連接字符串不正確引起的。

這是測試的簡單方法。

打開wp-config.php並找到以下幾行。

/** MySQL database username */
define('DB_USER', 'user_name');

/** MySQL database password */
define('DB_PASSWORD', 'user_password');

/** MySQL hostname */
define('DB_HOST', 'some_hostname');

接下來,在Azure管理門戶中打開您的WP網站。 轉到“配置”選項卡,然后向下滾動到“連接字符串”。 單擊“顯示連接字符串”。 將其復制到文本編輯器中,然后將值與wp-config.php中看到的值進行比較。 如果這些值不相同,則保留兩個副本並進行下一步。

接下來,打開您的本地shell並通過鍵入以下內容來打開mysqladmin,在下面替換上面的值(不帶單引號),請注意-p參數和密碼值本身之間沒有空格。

mysqladmin -u user_name -puser_password -h some_hostname

這些連接值之一應該是正確的,如果是這樣,則用不正確的值替換一個不正確的值。 如果兩種方法都不起作用,則返回到站點的Azure管理門戶,單擊“鏈接資源”,單擊出現的項目,您應該位於Clear DB管理門戶中,在這里您可以獲取MySQL數據庫的正確連接信息。

排序后,您可以配置WP Multi-site。 這是有關如何針對Azure Web Apps進行此操作的文章, http://azure.microsoft.com/zh-cn/documentation/articles/web-sites-php-convert-wordpress-multisite/

希望能有所幫助。

define( 'WP_ALLOW_MULTISITE', true );
define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', false);
define('DOMAIN_CURRENT_SITE', '');
define('PATH_CURRENT_SITE', '');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);

這些行添加到config.php並檢查wp-admin,有一個選項network admin。 轉到網絡管理員,然后從“網絡設置”選項轉到設置和設置網絡。

轉到站點選項,然后添加新站點。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM